ANAND AGRAWAL
ANAND AGRAWAL

Reputation: 58

displaying query results on sub form in MS access

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.

Upvotes: 0

Views: 3505

Answers (1)

Lee Mac
Lee Mac

Reputation: 16015

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.

Upvotes: 1

Related Questions