If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
How to update control
The AfterUpdate Event for a control cboName is NOT updating another
control txtCurTotals on the same form. What's wrong? The control txtCurTotals has the following Control Source: ="Current Selections = " & [TotalCount] TotalCount: DCount("Ingredient","zIngredientAndLocation","[NeedIt] = True") Private Sub cboName_AfterUpdate() Dim rs As DAO.Recordset Set rs = Me.Recordset.Clone rs.FindFirst "[IngredientID] = " & Me![cboName] If rs.NoMatch Then MsgBox "Record not found" Else Me.Bookmark = rs.Bookmark Me.NeedIt.Value = True Me.Refresh End If rs.Close Set rs = Nothing End Sub |
#2
|
|||
|
|||
How to update control
Try using Me.txtCurTotals.Requery rather than Me.Refresh.
-- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "esee" wrote in message ... The AfterUpdate Event for a control cboName is NOT updating another control txtCurTotals on the same form. What's wrong? The control txtCurTotals has the following Control Source: ="Current Selections = " & [TotalCount] TotalCount: DCount("Ingredient","zIngredientAndLocation","[NeedIt] = True") Private Sub cboName_AfterUpdate() Dim rs As DAO.Recordset Set rs = Me.Recordset.Clone rs.FindFirst "[IngredientID] = " & Me![cboName] If rs.NoMatch Then MsgBox "Record not found" Else Me.Bookmark = rs.Bookmark Me.NeedIt.Value = True Me.Refresh End If rs.Close Set rs = Nothing End Sub |
#3
|
|||
|
|||
How to update control
On Feb 19, 7:00*am, "Douglas J. Steele"
wrote: Try using Me.txtCurTotals.Requery rather than Me.Refresh. -- Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele (no e-mails, please!) "esee" wrote in message ... The AfterUpdate Event for a control cboName is NOT updating another control txtCurTotals on the same form. What's wrong? The control txtCurTotals *has the following Control Source: ="Current Selections = " & [TotalCount] TotalCount: DCount("Ingredient","zIngredientAndLocation","[NeedIt] = True") Private Sub cboName_AfterUpdate() * Dim rs As DAO.Recordset * *Set rs = Me.Recordset.Clone * *rs.FindFirst "[IngredientID] = " & Me![cboName] * *If rs.NoMatch Then * * * *MsgBox "Record not found" * *Else * * * *Me.Bookmark = rs.Bookmark * * * *Me.NeedIt.Value = True * * * *Me.Refresh * *End If * *rs.Close * *Set rs = Nothing End Sub I made the change, and the control does not get updated. |
#4
|
|||
|
|||
How to update control
On Feb 19, 7:49*am, esee wrote:
On Feb 19, 7:00*am, "Douglas J. Steele" wrote: Try using Me.txtCurTotals.Requery rather than Me.Refresh. -- Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele (no e-mails, please!) "esee" wrote in message .... The AfterUpdate Event for a control cboName is NOT updating another control txtCurTotals on the same form. What's wrong? The control txtCurTotals *has the following Control Source: ="Current Selections = " & [TotalCount] TotalCount: DCount("Ingredient","zIngredientAndLocation","[NeedIt] = True") Private Sub cboName_AfterUpdate() * Dim rs As DAO.Recordset * *Set rs = Me.Recordset.Clone * *rs.FindFirst "[IngredientID] = " & Me![cboName] * *If rs.NoMatch Then * * * *MsgBox "Record not found" * *Else * * * *Me.Bookmark = rs.Bookmark * * * *Me.NeedIt.Value = True * * * *Me.Refresh * *End If * *rs.Close * *Set rs = Nothing End Sub I made the change, and the control does not get updated. For those interested, I solved my problem. I still don't understand why my original AfterUpdate code didn't work, but this NEW AfterUpdate code works, and leaves me on the current at the same time. Private Sub cboName_AfterUpdate() Dim lngKeyVal As Long 'Save the value for the current record lngKeyVal = Me.cboName 'Requery the form Me.Requery 'Move back to the original record With Me.RecordsetClone ..FindFirst "[IngredientID] = " & lngKeyVal If Not .NoMatch Then Me.Bookmark = .Bookmark Me.NeedIt.Value = True Me.Requery Me.Refresh End If End With 'Move back to the original record...AGAIN With Me.RecordsetClone ..FindFirst "[IngredientID] = " & lngKeyVal If Not .NoMatch Then Me.Bookmark = .Bookmark End If End With End Sub |
#5
|
|||
|
|||
How to update control
"esee" wrote in message ... The AfterUpdate Event for a control cboName is NOT updating another control txtCurTotals on the same form. What's wrong? The control txtCurTotals has the following Control Source: ="Current Selections = " & [TotalCount] TotalCount: DCount("Ingredient","zIngredientAndLocation","[NeedIt] = True") Private Sub cboName_AfterUpdate() Dim rs As DAO.Recordset Set rs = Me.Recordset.Clone rs.FindFirst "[IngredientID] = " & Me![cboName] If rs.NoMatch Then MsgBox "Record not found" Else Me.Bookmark = rs.Bookmark Me.NeedIt.Value = True Me.Refresh End If rs.Close Set rs = Nothing End Sub |
Thread Tools | |
Display Modes | |
|
|