Morning Gentlemen. I have the following code in my report. All I want to do is show the dates the report is filtered on in the report header. These are the text boxes txtStart and txtEnd. The title is “List of jobs between txtStartDate and txtEndDate”. Or of the user doesn’t select a date then the caption just reads “List of IT helpdesk jobs”. Works great when the report is previewed (DoCmd.OpenReport rptName, acViewPreview, , wherecondition:="[Date Open]Between #" & StartDate & "# And #" & EndDate & "#") But when I use acViewNormal the text boxes are blank.
(Dates are selected from the form frmReports which is a listbox full of report names with two text boxes txtStartDate and txtEndDate)
Is my code in the wrong place..?
Private Sub Report_Activate()
On Error GoTo Error_Report_Activate
Dim strStart As String
Dim strEnd As String
Dim f As Form
If FIsLoaded("frmReports") Then
Set f = Forms!frmReports
If Not IsNull(f!txtStartDate) And Not IsNull(f!txtEndDate) Then
strStart = f!txtStartDate
strEnd = f!txtEndDate
Me.txtStart = strStart
Me.txtEnd = strEnd
Else
Me.txtRptTitle.Caption = "IT Helpdesk Jobs"
Me.txtAnd.Caption = ""
End If
End If
Exit_Report_Activate:
Exit Sub
Error_Report_Activate:
MsgBox Err.Description
Resume Exit_Report_Activate
End Sub
I hope this makes sense..?
(Dates are selected from the form frmReports which is a listbox full of report names with two text boxes txtStartDate and txtEndDate)
Is my code in the wrong place..?
Private Sub Report_Activate()
On Error GoTo Error_Report_Activate
Dim strStart As String
Dim strEnd As String
Dim f As Form
If FIsLoaded("frmReports") Then
Set f = Forms!frmReports
If Not IsNull(f!txtStartDate) And Not IsNull(f!txtEndDate) Then
strStart = f!txtStartDate
strEnd = f!txtEndDate
Me.txtStart = strStart
Me.txtEnd = strEnd
Else
Me.txtRptTitle.Caption = "IT Helpdesk Jobs"
Me.txtAnd.Caption = ""
End If
End If
Exit_Report_Activate:
Exit Sub
Error_Report_Activate:
MsgBox Err.Description
Resume Exit_Report_Activate
End Sub
I hope this makes sense..?