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

Form,Subform, And Query 1

Status
Not open for further replies.

AWilliams

Programmer
Mar 20, 2002
10
CA
I have a main form (Form A) displaying a combo box , a command button (Find), and a subform control. The combo box as two values to select from.

Based on the value selected from the combo box, when the user presses the command button the fields on the subform will be populated with associated values. When a value is selected from the combo box, one of two queries will be called to populate the fields on the subform.

If I assign the recordsource property on the subform to one of the queries, the main form displays the correct field. But I want the user to dynamically select which query to use to populate the subform fields.

Any idea how to proceed?
 
IS it really necessary to have two seperate queries for the subform? I would suggest that you try combine the two queries into one query - this is much better access design.
 
Dear AWilliams,

Try something like this on the afterupdate event of the combo box

If Me.combobox = "1" then
Me.subformxxxx.recordsource = "qryMyQuery1"
Else
Me.subformxxxx.recordsource = "qryMyQuery2"
End If
Me.subformxxxx.Requery

Note: I just assumed some names for the sake of typing a response.

Hope This Helps,
Hap [2thumbsup]


Access Developer [pc] - [americanflag]
Specializing in Access based Add-on Solutions for the Developer
 
Thanks Hap007, that code snippet was a big help and now the form enables the user to dynamically select one of two queries to populate textboxes on the subform.

AWilliams
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top