INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Paramater query runs twice in subform

Paramater query runs twice in subform

(OP)
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

RE: Paramater query runs twice in subform

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

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

RE: Paramater query runs twice in subform

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.

RE: Paramater query runs twice in subform

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.

RE: Paramater query runs twice in subform

This behavior is easily duplicated by create a query "Invoice_Number"

CODE --> 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 --> vba

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

RE: Paramater query runs twice in subform

(OP)
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

RE: Paramater query runs twice in subform

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close