PDA

Click to See Complete Forum and Search --> : MS Access Tables


Andrew
Dec 12th, 1999, 02:48 PM
I currently have a value in a text box tht I need to search for in a table, but i do not seem to be able to get the button on the form to take this value and search through the table i have created for the specific value. Any suggestion?

Cheers in advance

Andrew

john_murphy
Dec 12th, 1999, 03:16 PM
If your text box is text1 and the field name is a_number then open the database (eg table1) and do the following

table1.findfirst "a_number = " & text1.text

to test if it has found it use table1.nomatch which will be true if it does not find it.
Is this y9our answer???

john_m_murphy@hotmail.com

john_murphy
Dec 12th, 1999, 03:19 PM
Here is an example I use to logon (put the text in the click event of the command button

dim logon_data as recordset


Set logon_data = bar_data.OpenRecordset "users", dbOpenDynaset)
findstring = "user_no = '" & Text1.Text & "'"
logon_data.FindFirst findstring
If logon_data.NoMatch Then
MsgBox ("User does not exist")
Text1.Text = ""
user.Text = ""
Else
OK TO DO SOMETHING

endif

jritchie
Dec 13th, 1999, 09:21 AM
So txtText1 and cmdBtn and rsData
Your users enter a string to txtText1 and click cmdBtn to do a search for say name in rsData

Private cmdBtn.Clink....
'
' Test user entered something
'
If len(trim(txtText1)) > 0 then
rsData.FindFirst("Fieldname = '" & txtText1 & "'")
if rs.nomatch then
.
else
data found do whatever
end if
.
.
You can shorten this with the use of SQL to do a complete sweep of the recordset. If you want an example email me at jritchie@genauto.com

Hope it helps