Prompt user to input what data to be displayed on Report

  • Thread starter Thread starter Summing multiple fields on a form
  • Start date Start date
S

Summing multiple fields on a form

I've created a report. I would like for user to decide what dates they want
to see on report. (I think I need a parameter???? query)?

What type of query do I create where user is prompted to enter a 'Begin
Date' and and 'End Date'.. and have that data appear on report.

What are the steps to do this?????

Note: My date is in short date format
 
I've created a report. I would like for user to decide what dates they want
to see on report. (I think I need a parameter???? query)?

What type of query do I create where user is prompted to enter a 'Begin
Date' and and 'End Date'.. and have that data appear on report.

What are the steps to do this?????

Note: My date is in short date format

Create a select query on citiria between fromdate to enddate

Then create the report using this query.


Hopes it help....
 
Do yourself a favor and create a form with a couple text boxes [txtStartDate]
and [txtEndDate] for the user to enter the dates. Then use the command button
wizard to create a button to open your report.

This should create code like:

Private Sub cmdOpenReport_Click()
On Error GoTo Err_cmdOpenReport_Click

Dim stDocName As String
'== add these lines to match your field and control names ==
Dim strWhere As String
If Not IsNull(Me.txtStartDate) Then
strWhere = strWhere & " AND [YourDateField] >= #" & _
Me.txtStartDate & "# "
End If
If Not IsNull(Me.txtEndDate) Then
strWhere = strWhere & " AND [YourDateField] <= #" & _
Me.txtEndDate & "# "
End If
'===========================================
stDocName = "Order Details"
'add two commas and strWhere to the next line
DoCmd.OpenReport stDocName, acPreview, , strWhere

Exit_cmdOpenReport_Click:
Exit Sub

Err_cmdOpenReport_Click:
MsgBox Err.Description
Resume Exit_cmdOpenReport_Click

End Sub
 
Back
Top