VBA Coding a Parameter Query



I have a form that when is opened executes a parameter query. The user Types
in a date and poof the record set selected and only returns the desired date.
Once the parameter query has been established about 5 different 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 quieres like executing a parameter query does.
Does anyone know what code I would use to allow the contents of a Combo box
to create 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 with the Parameter query as its control source. The problem is the
first thing the parameter query wants, before running any code is a
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

Douglas J. Steele

Put Forms![NameOfForm]!ComboDate as the criteria in the query instead of

(replace "NameOfForm" with the appropriate name)

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question