I have a form to enter start and end dates then select a worker name to filter a report. This all works fine and when the report is open in preview mode it shows the date range in the txtboxes on the report header, but when I print the report the value for these txtboxes are #Name?
Here is the code
Date Range Form:
Private Sub cmdViewErrorRep ort_Click()
Dim stDocName As String
Dim stDocName2 As String
Dim stWhere As String
Dim stLinkCriteria As String
Dim lngLen As Long
stDocName = "Error Report"
stDocName2 = "Error Report - Date Range"
stLinkCriteria = " [ReviewDate] Between " & CLng(Nz(Me.txtB eginDate, txtEndDate)) & " And " & CLng(Me.txtEndD ate)
Me.Filter = stLinkCriteria
Me.FilterOn = Len(stLinkCrite ria)
If Not IsNull(Me.cboWo rker) Then
stWhere = stWhere & "([Worker] = """ & Me.cboWorker & """)"
DoCmd.OpenRepor t stDocName, acViewPreview, stLinkCriteria, stWhere
End If
DoCmd.Close acForm, stDocName2
DoCmd.RunMacro "PrintErrorRepo rt"
DoCmd.Close acReport, "Error Report"
End Sub
The controlsource property of the txtboxes on my report:
txtBeginDate:
=Forms.[Error Report - Date Range].txtBeginDate
txtEndDate:
=Forms.[Error Report - Date Range].txtEndDate
I know the code isn't pretty, I am still testing and have not added error checking yet but all is working except this part.
The only thing I haven't tried is changing the name of the report. Maybe the spaces and dash need to removed?
Help
Here is the code
Date Range Form:
Private Sub cmdViewErrorRep ort_Click()
Dim stDocName As String
Dim stDocName2 As String
Dim stWhere As String
Dim stLinkCriteria As String
Dim lngLen As Long
stDocName = "Error Report"
stDocName2 = "Error Report - Date Range"
stLinkCriteria = " [ReviewDate] Between " & CLng(Nz(Me.txtB eginDate, txtEndDate)) & " And " & CLng(Me.txtEndD ate)
Me.Filter = stLinkCriteria
Me.FilterOn = Len(stLinkCrite ria)
If Not IsNull(Me.cboWo rker) Then
stWhere = stWhere & "([Worker] = """ & Me.cboWorker & """)"
DoCmd.OpenRepor t stDocName, acViewPreview, stLinkCriteria, stWhere
End If
DoCmd.Close acForm, stDocName2
DoCmd.RunMacro "PrintErrorRepo rt"
DoCmd.Close acReport, "Error Report"
End Sub
The controlsource property of the txtboxes on my report:
txtBeginDate:
=Forms.[Error Report - Date Range].txtBeginDate
txtEndDate:
=Forms.[Error Report - Date Range].txtEndDate
I know the code isn't pretty, I am still testing and have not added error checking yet but all is working except this part.
The only thing I haven't tried is changing the name of the report. Maybe the spaces and dash need to removed?
Help
Comment