A
AHopper
On a form I have a command button that has the code below
in the On Click event. I am trying to print a report. I
have added a MsgBox to see what response I am
getting. "ReportDate" is a text box on the form formated
to 9/2/2004.
When I Click the button, the code seems to respond
correctly.
I get the first message box.
"Do you wan to print a day report for all jobs on the
selected date?"
When I respond "Yes" I do not get the second Message box
MsgBox "" & ReportDateCriteria & "" and I do not get a
printed report.
I use "" & ReportDateCriteria & "" three other times in
the same block of code with different If clauses, I get
the correct response and a printed report. The report
name is "rptRegisteredUniqueWeightSkidReport" "Shift"
and "JobNumber" are text boxes on the form.
I am trying to print a report for the selected day. The
other print options include Shift and/ or JobNumber. This
report appears to be the easiest one but I have not been
able to get it to print.
This is the code I have the problem with.
Dim stDocName As String
Dim ReportDateCriteria As String
stDocName = "rptRegisteredUniqueWeightSkidReport"
If IsDate(.ReportDate) And Nz(.Shift) < 1 And Nz
(.JobNumber) < 1 Then
Answer = MsgBox("Do you want to print a day report for
all jobs on the selected date?")
If Answer = vbYes Then
ReportDateCriteria = "[DatePacked] = " & Format
(.ReportDate, "\#mm/dd/yyyy\#")
MsgBox "" & ReportDateCriteria & ""
DoCmd.Hourglass True
DoCmd.Echo False
DoCmd.OpenReport stDocName, acNormal, ,
ReportDateCriteria
DoCmd.Hourglass False
DoCmd.Echo True
Exit Sub
End If
Thank you for your time and support.
Allan
in the On Click event. I am trying to print a report. I
have added a MsgBox to see what response I am
getting. "ReportDate" is a text box on the form formated
to 9/2/2004.
When I Click the button, the code seems to respond
correctly.
I get the first message box.
"Do you wan to print a day report for all jobs on the
selected date?"
When I respond "Yes" I do not get the second Message box
MsgBox "" & ReportDateCriteria & "" and I do not get a
printed report.
I use "" & ReportDateCriteria & "" three other times in
the same block of code with different If clauses, I get
the correct response and a printed report. The report
name is "rptRegisteredUniqueWeightSkidReport" "Shift"
and "JobNumber" are text boxes on the form.
I am trying to print a report for the selected day. The
other print options include Shift and/ or JobNumber. This
report appears to be the easiest one but I have not been
able to get it to print.
This is the code I have the problem with.
Dim stDocName As String
Dim ReportDateCriteria As String
stDocName = "rptRegisteredUniqueWeightSkidReport"
If IsDate(.ReportDate) And Nz(.Shift) < 1 And Nz
(.JobNumber) < 1 Then
Answer = MsgBox("Do you want to print a day report for
all jobs on the selected date?")
If Answer = vbYes Then
ReportDateCriteria = "[DatePacked] = " & Format
(.ReportDate, "\#mm/dd/yyyy\#")
MsgBox "" & ReportDateCriteria & ""
DoCmd.Hourglass True
DoCmd.Echo False
DoCmd.OpenReport stDocName, acNormal, ,
ReportDateCriteria
DoCmd.Hourglass False
DoCmd.Echo True
Exit Sub
End If
Thank you for your time and support.
Allan