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

Parameter Query in a Form

Status
Not open for further replies.

ajolson1964

Programmer
Mar 25, 2008
31
US
I have a form that when is opened executes a parameter query. What happens is the form opens and the first thing asked is to enter a date, so the user Types in a date (fat fingers) and poof the record set selected and only returns the desired date.
Once the parameter query has been established about 5 different “Sub queries (that are based on the original parameter query) are set and the user then is able to print out a variety of reports.

What I don’t like is that the user has to “Fat-Finger’ in the Date. I would
rather them select a date from a combo box and have that fill in the
parameter query.

I have tried everything I can to make that happen. Tried
Filtering yada yada yada but that only filtered the query and did not pass
that along to the sub queries like executing the original parameter query does.
Does anyone know what code I would use to allow the contents of a Combo box to be passed along to a parameter query?

This is what I have done so far. I have set up a Form that has a combo box(with a series of Date) in it and a command button. The user selects the date then clicks on the command button. The command button then opens a form that has a Parameter set. The problem I am having is first thing the parameter query wants, before running any code is a “Fat-Fingered” date. It just wont execute any code.

Here is my code
FYI ***[StartDate] is the parameter that controls the[DayofProduction]
field within the query.

Private Sub Command2_Click()
Dim stDocName As String
Dim stLinkCriteria1 As String
stDocName = "AllWeeklyReportFirstSort"
stLinkCriteria1 = "[Startdate] =" & Format(Me.ComboDate, "\#mm\-dd\-yyyy\#")
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria1, acFormReadOnly
End Sub
[StartDate] is the parameter that controls the DayofProduction field
 
In the query change the name of the parameter to something like this:
[Forms]![your parameter form]![ComboDate]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top