REFRESH / REQUERYCODE - PLEASE HELP..

C

clawdogs

Hi. I have the following code that works up until Me.Requery. I
can't get the code to go to the specified record after Me.Requery.
Control name is COFID and control source is COFID. Someone please
help.

Private Sub COFID_AfterUpdate()
Dim lngKeyVal As Long

lngKeyVal = Me.COFID

Me.Refresh

'Move back to the original record - this doesn't seem to work...
With Me.RecordsetClone
..FindFirst "[COFID] = " & lngKeyVal

End With

End Sub
 
M

Marshall Barton

Hi. I have the following code that works up until Me.Requery. I
can't get the code to go to the specified record after Me.Requery.
Control name is COFID and control source is COFID. Someone please
help.

Private Sub COFID_AfterUpdate()
Dim lngKeyVal As Long

lngKeyVal = Me.COFID

Me.Refresh

'Move back to the original record - this doesn't seem to work...
With Me.RecordsetClone
.FindFirst "[COFID] = " & lngKeyVal

End With

End Sub

You need to sync the form's recordset with its recordset
clone:

With Me.RecordsetClone
.FindFirst "[COFID] = " & lngKeyVal
If Not .NoMatch Then Me.Bookmark = ,Bookmark
End With

Or in this special situation, you can get away with:

Me.Recordset.FindFirst "[COFID] = " & lngKeyVal
 
C

clawdogs

Thanks. This is what finally worked for me:

Private Sub COFID_AfterUpdate()
Dim lngID As Long

lngID = Me.COFID
Me.Requery

RecordsetClone.FindFirst "COFID=" & lngID
Bookmark = RecordsetClone.Bookmark

'only used the below refresh because the first record's data kept
appearing in the COFID field
Me.Refresh

End Sub


Thanks again!
 

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