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!

displaying by id

Status
Not open for further replies.

punkdyke

Technical User
Jun 27, 2003
3
US
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)

Maybe this will help

 
change the line
If str(key_number) = key_find Then Exit Do

to

If key_number = val(key_find) Then Exit Do

so tit will work

sorry
 
Hello punkdyke

2 methods suggested

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

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top