Searching Table Help

YUPAPA

Registered User.
Local time
Today, 23:25
Joined
Sep 28, 2002
Messages
11
HiHi, :)

I have a form (client_FRM), a table (client_TBL). I have textboxes for all the fields in client_TBL on my form. All my textboxes are unbound. Also I have a button called 'command0'. I want to search for the firstname in client_TBL. How do I search the table and output the result?

My textbox is named 'client_firstname'. And the fieldname of the firstname in client_TBL is named 'client_firstname' also.

I've tried to use the code below for my find button (command0) but it is not workin...

Code:
Private Sub command0_Click() 
Me.RecordsetClone.FindFirst "[client_firstname] = " & Me![client_firstname] 
Me.Bookmark = Me.RecordsetClone.Bookmark 
End Sub

Thank you. I am a newbie sorry. :o :(
 
Hi,

I got it workin now... but how do I make a Msgbox to show that the record is found or not??
If it is found, it will then show MsgBox("Record is found")

Thank you
 
Two options...

Make the field you're searching a dropdown box with limittolist set to yes, then there will always be a match, or use the recordset method.

Instead of doing a findfirst on the form, use the findfirst method of the recordset to determine if a match was found, otherwise give a message.

Stick an If statement into the code after the findfirst so

Dim rs as Recordset
Set rs = CurrentDB.OpenRecordset("TableName")

rs.FindFirst ...
If rs.NoMatch = true then
msgbox "no record found"
Else
Me.Bookmark = rs.Bookmark
End if

rs.close
set rs = nothing

HTH
 

Users who are viewing this thread

Back
Top Bottom