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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching for a record

Status
Not open for further replies.

laruajo

MIS
Sep 16, 2002
24
US
I have a form that is based on a query with a 5 digit number as the primary key. I would like to be able to search for a specific record based on that number in the form. Here is a little background, when the form is opened it prompts for the password then for the first number they wish to search for. The user goes in the form and enters the data, but if they would like to update another record they have to exit the form and then re-enter, this mean re-entering the password as well. I would like a way for the user to move from record to record while in the form. I tried using the wizard to create a command button to search but this does not work because when the form is opened it prompts the user for a number so the search button sees this as being the only record in the query (the first search is done in the query) so it says it cannot find the record. I hope this all makes sense. How can I allow users to search within the form? Do I need to modify the setup now and take the first search out of the query and do it some other way? Any suggestions would be appreciated. Thank you

 
Hi

More than one way to do this, but...

In code make an SQL string using the number entered by the user, so assuming form is based on a single table

strSQL = "SELECT * FROM MyTable WHERE Id = " & Me.Id & ";"
Me.RecordSource = strSQL
Me.Requery

you need to use your own table name, control names etc Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Another idea, put a combo box in the header of the form that finds a record based on a selection. When you activate the combo box wizard it will walk you through your choice of action and fields.

Good luck

Dawn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top