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

Paramater query runs twice in subform

Status
Not open for further replies.

Moss100

Technical User
Aug 10, 2004
579
0
16
GB
Hello I am displaying my query results in an unbound subform [Sub_Query_Display]

Querys without parameters work fine, but when I set the subform with a query that has a paramater the paramter is requested twice. I can not see why this is happening.

The code used to set the subform is:

Code:
Sub_Query_Display.SourceObject = "query.Invoice_Number"

Many thank for any suggestions.

Regards

Mark

 
That's just another reason why you should never use parameter prompt queries.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Set some break points in your code and step thru it to find out where and why this query is called.

Have fun.

---- Andy

There is a great need for a sarcasm font.
 
Depending on what event this is in I can see this definitely running twice. Show complete code.

Exaple. The source object of the subform is already set. Forms load from the inside out. Subforms then mainform. So it would prompt you on the subform load, then if you set the sourceobject in the main forms load event it would prompt agains.

FYI. Your subform is bound, it is just not linked to the mainform. Two different concepts.
 
This behavior is easily duplicated by create a query "Invoice_Number"

SQL:
SELECT *
FROM tblCustomers WHERE City = [Enter a City Name];

Then create an unbound form with a subform control "Sub_Query_Display" but no SourceObject. Add a button that sets the SourceObject

Code:
Sub_Query_Display.SourceObject = "query.Invoice_Number"
Opening the form doesn't cause any prompt. Clicking the button to set the SourceObject will prompt the user twice with "Enter a City Name".

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Thanks all.

Duane - yes this is exactly the behaviour I am getting.

Is setting the subform sourceobject forcing the main form to reload and then triggering the query a second time?

Thanks Mark

 
I'm not sure why it happens but know how to stop it. Don't used parameter queries.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top