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

Displaying Queries in Sub Forms by Field

Status
Not open for further replies.

WantoN

ISP
Jul 4, 2005
22
0
0
GB
Hey guys,
In relation to my post before, I have a problem regarding populating a subform with a query, whose information is based on the selection in a listbox.

I have four listboxes, who're linked as to ultimately select one company, and I want to display said company's employees in the subform.

I have created a query with the relevant fields, and have entered in the criteria of the CompanyName field: - [Forms]![ContactLookup]![cboCompanyName]

I have then created a command box, which I presume I need to code to populate the subform with the queried data. However, I don't know how to do this, and haven't managed to work it out from the faqs available.

All helps is much appreciated,
Antoni
 
Set the RecordSource of the subform to your query.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
That has been done, but as the user may want to alter to the information in the listbox multiple times, surely I will need a cmdbox and a way of requerying the data inside the subform, so that it can be done more than once?

Perhaps I'm being stupid?

Antoni
 
Have a look at the Requery method of the Form object.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I've sorted the problem :)

I stupidly didn't think of simply adding a requery statement to the cmdbox.

To clarify, I added the following the form code:

Private Sub cmdCriteriaLookup_Click()
subCriteriaLookup.Requery
End Sub

Where "cmdCriteriaLookup" is the command button and subCriteriaLookup is the form whose source is the query.

Thanks guys,
Antoni
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top