How to update control


E

esee

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
 
Ad

Advertisements

E

esee

Try using Me.txtCurTotals.Requery rather than Me.Refresh.

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no e-mails, please!)


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.
 
Ad

Advertisements

E

esee

Try using Me.txtCurTotals.Requery rather than Me.Refresh.
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top