Parameter Query question

JeffreyDavid

Registered User.
Local time
Today, 20:57
Joined
Dec 23, 2003
Messages
63
I have a form with 3 subforms. Each subform has it own parameter query and all parameter queries are the same, copied and pasted. If I open the main form now, it asks me 3 times to input the start date and ending date. I don't want my users to have to type the starting date and ending date in 3 times each time the form is opened. If I set the parameter query to the main form, the subforms don't recognize the parameter query and lists everything.
Is there any way I can have a main form open, using the parameter query of the main form instead of using 3 parameter queries to query 3 subforms within my main form?
 
Here is one way to do it:

Add 2 unbound controls to your main form and make them non-visible. Set up your queries to reference these 2 form controls as start and end date criteria instead a parameter entry. Then in the On Open event of your form set up 2 input boxes to fill these 2 controls with your start and end dates and finally requery all 3 subforms.

Just a sample of the code:

Dim EnterDate as Date
EnterDate = InputBox ("Please Enter Start Date")
Me.txtStartDate = EnterDate
EnterDate = InputBox ("Please Enter End Date")
Me.txtEndDate = EnterDate
Me.Subform1.Requery
Me.Subform2.Requery
Me.Subform3.Requery


There may very well be a better recommended way to do this but this is one option.
 
Another way to do it is to have a popup form and have the query look at the criteria that the user puts in the txt boxes. Don't know how to do this? See attach ment

also I have heard of a way to have a calandar to pop up when the user clicks on the txt box. try google to search for this.

Good luck
 

Attachments

RichO, I am trying to set up my queries to reference the 2 controls StartDate and EndDate, instead of a parameter query, but am having problems. The code I put in the criteria is:
Between [Forms]![Management STATS]![txtUnbound1] And [Forms]![Management STATS]![txtUnbound2]
But the subforms are not recognizing the input in those 2 controls.
Is something wrong with my code? Or is something else missing ......
 
Try making those 2 unbound controls visible so you can see what's in them. That will at least tell you if the controls hold the correct values and help narrow down the problem.
 
The attachment will show you how to do this (it is a tutoral). I forget which page it was but it is just a tutoral on parameter queries. and not very big.
 
Thank You for all your advise gentlemen, it now works. This made it work:
Add 2 unbound controls to your main form and make them non-visible. Set up your queries to reference these 2 form controls as start and end date criteria instead a parameter entry. Then in the On Open event of your form set up 2 input boxes to fill these 2 controls with your start and end dates and finally requery all 3 subforms.

Just a sample of the code:

Dim EnterDate as Date
EnterDate = InputBox ("Please Enter Start Date")
Me.txtStartDate = EnterDate
EnterDate = InputBox ("Please Enter End Date")
Me.txtEndDate = EnterDate
Me.Subform1.Requery
Me.Subform2.Requery
Me.Subform3.Requery
 
Here is one way to do it:

Add 2 unbound controls to your main form and make them non-visible. Set up your queries to reference these 2 form controls as start and end date criteria instead a parameter entry. Then in the On Open event of your form set up 2 input boxes to fill these 2 controls with your start and end dates and finally requery all 3 subforms.

Just a sample of the code:

Dim EnterDate as Date
EnterDate = InputBox ("Please Enter Start Date")
Me.txtStartDate = EnterDate
EnterDate = InputBox ("Please Enter End Date")
Me.txtEndDate = EnterDate
Me.Subform1.Requery
Me.Subform2.Requery
Me.Subform3.Requery

There may very well be a better recommended way to do this but this is one option.

**I am having a similar issue...I have a Main form that has 2 subforms, which get their information via separate forms, which get their information from parameter queries. The reason for the separate forms is a formatting issue...

My problem is that I can't get my Main form to pass either of the parameters to their respective subforms. Any ideas? How would you "Set up your queries to reference these 2 form controls"?
 

Users who are viewing this thread

Back
Top Bottom