How to update control

  • Thread starter Thread starter esee
  • Start date Start date
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
 
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.
 
Try using Me.txtCurTotals.Requery rather than Me.Refresh.
news:102a428d-a31c-4be1-95c4-db6e85d1879c@f15g2000yqe.googlegroups.com....
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
 
Back
Top