By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,122 Members | 927 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,122 IT Pros & Developers. It's quick & easy.

Names and Dates

P: n/a
I have a combo box with several names, once a name is selected then it
goes and gets a report of the name of the person that has been
selected.

I would like to put this and date selection on one form, the query
won't run, it says that there is too many parameters.

so select name then select dates that you would like to pull up and
then put this into a report.

Any help would be greatly apprectiated... as no idea where to turn on
this one.

Elaine
Jan 9 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Elainie wrote:
I have a combo box with several names, once a name is selected then it
goes and gets a report of the name of the person that has been
selected.

I would like to put this and date selection on one form, the query
won't run, it says that there is too many parameters.

so select name then select dates that you would like to pull up and
then put this into a report.

Any help would be greatly apprectiated... as no idea where to turn on
this one.

Elaine
Assuming the combo is called ComboName and the dates are FromDate and
ToDate and the date field in the table is DateFld, your code make look
something like
Docmd.OpenReport Me.ComboName,,,_
"DateFld Between #" & Me.FromDate & "# And #" Me.ToDate & "#"
This assumes both dates are filled in.

Do you create a separate report for each person's name or did you want
to filter the report on the persons name? Let's pretend you wanted to
filter on a person's name and date range. Your code may be similar to
the following (dates surrounded by #, strings by ' or "")

Dim strFilter as string
If Not IsNull(Me.ComboName) Then
strFilter = "TableNameFld = '" & Me.ComboName & "' And "
Endif
If Not IsNull(Me.FromDate) Then
strFilter = strFilter & "DateFld >= #" & Me.FromDate & "# And "
Endif
If Not IsNull(Me.ToDate) Then
strFilter = strFilter & "DateFld >= #" & Me.ToDate & "# And "
Endif

'if there is a filter, remove the trailing 'And'
If strFilter "" Then strFilter = Left(strFilter,Len(strFilter)-5)
Docmd.OpenReport YourReportName,,,strFilter
Jan 9 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.