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!

beginner question - creating a form that displays multiple data

Status
Not open for further replies.

AidanCambel

Technical User
Jun 25, 2001
7
US
I apologize for this question - its probably really simple and I just can't figure it out. I have a data base that has multiple rows of information for each customer.

ex.

ab | 1 | 2 | 4 |
ab | d | f | e |

and so forth. I want a form that I can key in "ab" and see the results for all the fields that have that customer number. right now when i try it, a get a form response for each row.

Does this make sense? Can I do this?

Thanks.
 
It's relatively easy to do. Make a form with a textbox on it (I'll call it txtCriteria). Next you have to make a query to pull the appropriate data. Make the query with the fields you need and in the criteria of the ID field put this:

[Forms]![MyFormName]![txtCriteria]

Now when you run that query it will look for MyFormName and match txtCriteria to the ID field and only pull records that match. You can test this by opening up the form, keying in an ID and then viewing the query results. Now that we have the query, we have to make a subform based on that query and insert it into MyFormName. Name the subform object you inserted, I'll call it MySubFormObject for this demonstration. The last step is to make a command button (cancel the wizard if it comes up) on MyFormName and put the code in to show the relevant data after putting an entry in txtCriteria. In the OnClick event of the command button, select Code Builder and put this statement in the VBA window:

MySubFormObject.Requery

That tells the query to be run again and show the data on the subform. There ya have it, a working example of a search form.

HTH Joe Miller
joe.miller@flotech.net
 
Thanks! vI am going to try it this afternoon and see if I can figure out how to make it work.

Thank you so much for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top