Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find record on a form

Status
Not open for further replies.

ohmbru2

Technical User
Jul 24, 2001
51
US
I've searched this forum (and the Access Forms forum) and found some help, but the code I came up with doesn't work. I'm trying to display a record on a form based on the value of a field on a different form. Sometimes this did take me to the correct record, but I haven't figured out why. For example, the first attempt may succeed, but subsequent attempts would fail. There is no error message, but the form does not advance to the record. This code would be executed from the form SomeForm by a button click as the last part of a larger module, but for now I just have it as it's own module with the form frmAgent open.

Dim strID As String
strID = Forms!SomeForm!SomeField
Dim rst As Dao.Recordset
Set rst = Forms.frmAgent.RecordsetClone
rst.MoveFirst
rst.FindFirst "[ID] = '" & strID & "'"
Forms.frmAgent.Bookmark = rst.Bookmark
End Function
 
And what about something like this ?
With Forms!frmAgent
.Requery
DoEvents
.Recordset.FindFirst "[ID]='" & Me![SomeField] & "'"
End With

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top