# Creating a search field in MS Access Form



## Fatmah (Feb 9, 2001)

HELP, HELP, HELP!

On the form that I have on my Access Database, I would like to add a field in the form so that I can do a search by ID # and hence pull up the information for the record matching this ID #.

I am somewhat familiar with Access. I would really appreciate any help that you could provide.

Thanks

Fatmah


----------



## Anne Troy (Feb 14, 1999)

Doesn't the form wizard automatically give you the id field to type into? Are you saying you want a dropdown box instead of the regular field-type box?


----------



## YSB (Mar 7, 1999)

The easiest way to do this is with VB. Create a textbox in the forms header or footer and name it (at least for my example) txtIdFind. Create a command button next to it marked 'Find' and named cmdFind. Then put the following code into the command button (in the forms VB Code module).

Private Sub cmdFind_Click()

Me.Recordset.FindFirst "[NameOfIdField] = " & NZ(Me!txtIdFind,0)

End Sub

That should do it. Let us know how it goes. Good Luck!


----------



## iam7617115 (Jan 14, 2003)

i am having the same problem.. and i did that.. but it wont work.. i changed the field name to exactly that.. and then the command button as well.. i copied the code into the vb editor and it wont work when i click the button.. wat is going wrong?


----------

