Requery a query in a subform

papadega3000

Registered User.
Local time
Today, 07:06
Joined
Jun 21, 2007
Messages
80
I have a main form setup with pages the first page (page0) is a search page which has combo boxes to list the items in 2 separate tables and the user will be able to pick selections and view those selections in the other 4 pages.

The other four pages consist of a subform that is a query. These queries are based off the input from the search page.

My problem is I can't get the subform queries to refresh after the search button is hit. If I select certain criteria and open the table directly it will display the correct results based of the search page.

I have the query setup as the following code in the criteria section of the select query.


IIf(IsNull([Forms]![Mainform]![ComboBox1]),[Field to Display if Null],[Forms]![MainForm]![ComboBox1])

IIf(IsNull([Forms]![Mainform]![ComboBox2]),[Field to Display if Null],[Forms]![MainForm]![ComboBox2])

IIf(IsNull([Forms]![Mainform]![ComboBox3]),[Field to Display if Null],[Forms]![MainForm]![ComboBox3])

Page0 has the combo boxes and a search button which I was going to use to control the requery. which would requery all the tables and display the results in the subforms.

Using a On_Click() procedure:

Private Sub CommandSearch_Click()
[Forms]![MainForm]![Page1].Requery
[Forms]![MainForm]![Page2].Requery
[Forms]![MainForm]![Page3].Requery
[Forms]![Mainform]![Page4].Requery
End Sub

This will not display the actual query that is determined by the search page. How can I get the subform to show what the actual query is based off those combo boxes?

Is there a problem with my Requery statement?
 
I actually figured this one out from another forum post. In the On_Click().

The code was wrong. Instead of defining the requery as explained in the previous post.

The correct code is :

Me.SubformName.Form.Requery

In my case I hade four different subforms so I had four lines with the SubformName referencing the subform intended.
 

Users who are viewing this thread

Back
Top Bottom