0
votes

I have a Form A (Main form) with combo box taking values from a account master table. Whichever value a user will select from combo box is displayed on the same form in 2 text boxes. Now on pressing a button (On Form A) a query A runs after taking the values in 2 text boxes as inputs.

The results are displayed correctly in a separate tab created automatically in datasheet view.

However I want to display the results on a sub form on the Main form A. I have bound this sub form with the Query A and have placed this sub form on form A.

But still the query results are getting displayed in a separate tab and not on the sub form which seems to do nothing.

Please help.

1
What is the subform bound to : can you post up the exact syntax? It should be something like 'query.yourqueryname' - Minty
sub form is bound to the query that gets executed on pressing the command button on the main form. So the bound query is a separate object and the query name is selected in the record source drop down in the form properties window. So there is no syntax for it. - ANAND AGRAWAL
There is code. The code that runs when your button is pressed. If that code is opening a query, instead of re-querying the sub-form, that would explain that you are doing wrong. - SunKnight0

1 Answers

1
votes

If the results of the query that you are using as the Source Object for your subform are using the values of the comboboxes as query criteria, you may need to call SubformName.Requery after changing the combobox values.


If instead you are modifying the SQL behind your query rather than using criteria, I have found that you need to issue the following in order for the results to update:

SubformName.SourceObject = Subform.SourceObject

In my experience, when the SQL behind a query that is used as the Source Object for a subform is modified, the data displayed by the subform is not updated following a call to .Requery, but only after the SourceObject property is 'refreshed' using the method shown above.