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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching through records on form for requested string

Status
Not open for further replies.

eussias

Programmer
Sep 25, 2001
97
AU
I have an Access 2000 VBA application setup. Currently there are 7 forms, all of which have one common field of Client_Num, which is numeric. I have now placed a text box on each form where the user is able to enter the Client_Num they require. When they press a Command button I want to search through all the records on the active form, and go to the appropriate record. I've tried using the DoCmd.GoToRecord but am not having any luck. Can anyone give me any suggestions on this? Cheers.
 
MyValue=55 'set the criteria

' Find the record that matches the value.
Me.RecordsetClone.FindFirst "[ID] = " & MyValue
Me.Bookmark = Me.RecordsetClone.Bookmark
 
Tried that but had no luck... invalid argument.
 
khmm..replace ID to Client_Num
Me.RecordsetClone.FindFirst "[Client_Num] = " & MyValue
Me.Bookmark = Me.RecordsetClone.Bookmark

I inserted it into the code of the searched form. You must yield the the value (MyValue variable) to search/compare.

if it don't works try something like that (because of the "me" variable it must to be in the code of searched form, or replace it the exact ...):

Dim rst As Recordset, myBookmark As String
Set rst = CurrentDb.OpenRecordset("SELECT * FROM MyTable")
on error resume next
rst.MoveFirst
Do While Not rst.EOF
if rst.Fields("Client_Num")= MyValue then
myBookmark = rst.Bookmark
Exit Do
rst.MoveNext
Loop
me.Bookmark = myBookmark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top