Prompt user to input what data to be displayed on Report

  • Thread starter Summing multiple fields on a form
  • 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
 
H

HC

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....
 
S

Summing multiple fields on a form

Thx Hc...but how do I make the query as part of the report???
 
D

Duane Hookom

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
 

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