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

Code Assistance

Status
Not open for further replies.

asmall

Programmer
Dec 26, 2002
31
US
I'm trying to create a form where the user could type in the info they want(for instance account number), query the database and open another form showing the results of the query. Do i set up the recordsource in the form i'm opening or in the click button on the main form?
 
There are a couple of ways you could do this. Your form could contain a subform. The subform is linked to the account text box of the main form. Then, when the user enters an account number the subform is automatically requeried. This is the way I would recommend.

If you want to popup a new form, I would initially Open the 2nd form with the visible property of the form set to False. Then, on the AfterUpdate event of the Account text box, I would filter the 2nd form (or reset its RowSource Property) and set it's visible property to True. (I would recommend using the filter way of doing it.) I would then leave the visible property set to True from that point on. The code to filter the 2nd form would be something like this:

frm2ndForm.Filter = "strAccountNumber = '" & txtAccount & "'"
frm2ndForm.FilterOn = True


To requery the 2nd form, type something like this:

frm2ndForm.RowSource = "Select * from YourTable Where strAccountNumber = '" & txtAccount & "';"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top