I am trying to let the user enter a value in a textbox on a form, search for that value in a table field, and show that specific record. How can I do this?
I realized that that sounded pretty dumb ... and not very imformative. So here's a better explaination of what I need to do...
I have a switchboard form from which I access various other forms. For one of these, I need to be able to type the "key number" into a text box (or somehow enter it) and then go to the record with that same "key number" on a form called "CashKey". Please help?
this is one way to do it, sorta bad, but works if you dont have too many records.
On your form make a text box and name it: key_find do not give it a control source
also make sure you have a text box named key_number that has a control source of key number
on the key_find text box properties, go to "on key down" and click the "..." button and choose "code builder"
that will bring up the Visual Basic editor.
type the following code between the "Private Sub" and "end sub" lines
If KeyCode = 13 Then
On Error GoTo done
DoCmd.GoToRecord , , acFirst
Do
If str(key_number) = key_find Then Exit Do
DoCmd.GoToRecord , , acNext
Loop
End If
done:
Ok, now what this does is go through the records one at a time until it gets to the record you are looking for.
It assumes that [key number] is a NUMERICAL value, not a string (has only numbers)
1 Put a command button on form with text box (with toolbox wizard on)
Select Form Operations and Open form
Select the form to open and select the find specific data radio button.
Select the items to match and proceed through the wizard
2 With wizard off
Add a command buuton - place the following in the click event
Dim myCriteria As String
myQuery = "[ID]=" & txtID
DoCmd.OpenForm "Instructor", , , myQuery
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.