Report using Parameter query

M

Mahesh

Hi

I have a report which runs through the query and has the following
parameters .
1. Enter Ethnic Group
2. Enter Starting Date
3. Enter Ending Date

I have only one date field in the original field which I put a criteria
as: BETWEEN ( Ending Starting Date ) AND ( Enter Ending Date ).

As of now, the report works fine. When opened it asks for the above
parameters.

This is what I would like to have:

Put all the three parameters in one dialog box. and also Ethnic group
field must be a drop down box.

I have already created form with the drop down box and two dates field.

But I am unable to go ahead from here.

How do I open the report from this dialog box form.

Is is possible and if yes, what is the code ?

Thanks

Mahesh
 
D

Duane Hookom

First make sure your form and controls have descriptive names. Then use the
command button wizard to create a button that opens the report. Remove
criteria and parameters from the report's record source. Modify the code
created by the command button wizard to something like:

Dim strWhere as String
strWhere = "1=1 "
If Not IsNull(Me.cboEthnicGroup) Then
strWhere = strWhere & " And [EthnicGroup]=""" & _
Me.cboEthnicGroup & """ "
End If
If Not IsNull(Me.txtStartDate) Then
strWhere = strWhere & " And [DateField] >=#" & _
Me.txtStartDate & "# "
End If
If Not IsNull(Me.txtEndDate) Then
strWhere = strWhere & " And [DateField] <=#" & _
Me.txtEndDate & "# "
End If
DoCmd.OpenReport "rptYourReport", acPreview, , strWhere
 

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

Top