Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting dates to print on report

Status
Not open for further replies.

dotolee

Technical User
Jan 27, 2008
134
CA
i've created a report that gets 2 date parms from a form (let's just called it formABC)
It works great - the data is filtered by the date range provided.
But now I need to print the actual dates on the report.
My code to launch the report looks like:

Private Sub cmdRunReport_Click()
Dim strReport As String 'Name of report to open.
Dim strField As String 'Name of your date field.
Dim strWhere As String 'Where condition for OpenReport.
Const conDateFormat = "\#mm\/dd\/yyyy\#"

strReport = "Test Stats"
strField = "WarmXferDate"

If IsNull(Me.txtStartDate) Then
If Not IsNull(Me.txtEndDate) Then 'End date, but no start.
strWhere = strField & " <= " & Format(Me.txtEndDate, conDateFormat)
End If
Else
If IsNull(Me.txtEndDate) Then 'Start date, but no End.
strWhere = strField & " >= " & Format(Me.txtStartDate, conDateFormat)
Else 'Both start and end dates.
strWhere = strField & " Between " & Format(Me.txtStartDate, conDateFormat) _
& " And " & Format(Me.txtEndDate, conDateFormat)
End If
End If

DoCmd.OpenReport strReport, acViewPreview, , strWhere
End Sub

 
Just put a textbox on the report, set it's control source property to:

=Forms!formABC!txtEndDate

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top