J
JOM
I have the following code for my preview button. On my form i have an option
group and 2 unboud textboxes to enter dates for some of the information in
the option group would require one to enter...
So options 1,2,5,7 requires one to enter the date while 3,4,6 dont require
one to enter the date.
My code is doing the opposite, it opens the form or reports and a popup
messagebox says I need to enter the date. While 1,2,5,7 which require the
date dot do so Where am wrong?
Sub PrintReports(PrintMode As Integer)
On Error GoTo Err_Preview_Click
' This procedure used in Preview_Click and Print_Click Sub procedures.
' Preview or print report selected in the ReportToPrint option group.
Dim DocName As String
Dim strControl As String
Const conIncomeRqst = 1
Const conPerComplRqst = 2
Const conVerStatusRqst = 5
Const conVerOutOfStd = 7
Const conWeeklyComplRqst = 3
Const conMonthlyComplRqst = 4
Const conYearlyComplRqst = 6
strControl = ""
If Me!Frame0.Value <> conWeeklyComplRqst <> conMonthlyComplRqst <>
conYearlyComplRqst Then
If IsDate(txtBeginDate) And IsDate(txtEndDate) Then
If CDate(txtEndDate) < CDate(txtBeginDate) Then
MsgBox "The ending date must be later than the beginning
date."
txtEndDate.SetFocus
Exit Sub
End If
Else
'MsgBox "Use valid dates for the beginning and ending date
values."
strControl = strControl & "Use valid date values for beginning
and ending" & vbCrLf
'Exit Sub
End If
End If
Select Case Me!Frame0
Case 1
DoCmd.OpenReport "New Requests", PrintMode
Case 2
DoCmd.OpenReport "Completed Requests", PrintMode
Case 3
DoCmd.OpenForm "Weekly Report", acNormal
Case 4
DoCmd.OpenReport "Monthly Report", PrintMode
Case 5
DoCmd.OpenReport "Status Report", PrintMode
Case 6
DoCmd.OpenReport "Year To Date", PrintMode
Case 7
DoCmd.OpenReport "Outstanding Report", PrintMode
End Select
If strControl <> "" Then
MsgBox "Following information required:" & vbCrLf & strControl,
vbInformation, "Incomplete Information"
End If
Exit_Preview_Click:
Exit Sub
Err_Preview_Click:
Resume Exit_Preview_Click
End Sub
Private Sub Preview_Click()
' Preview selected report. This procedure uses the PrintReports
' Sub procedure defined in (General) section of this module.
PrintReports acPreview
End Sub
group and 2 unboud textboxes to enter dates for some of the information in
the option group would require one to enter...
So options 1,2,5,7 requires one to enter the date while 3,4,6 dont require
one to enter the date.
My code is doing the opposite, it opens the form or reports and a popup
messagebox says I need to enter the date. While 1,2,5,7 which require the
date dot do so Where am wrong?
Sub PrintReports(PrintMode As Integer)
On Error GoTo Err_Preview_Click
' This procedure used in Preview_Click and Print_Click Sub procedures.
' Preview or print report selected in the ReportToPrint option group.
Dim DocName As String
Dim strControl As String
Const conIncomeRqst = 1
Const conPerComplRqst = 2
Const conVerStatusRqst = 5
Const conVerOutOfStd = 7
Const conWeeklyComplRqst = 3
Const conMonthlyComplRqst = 4
Const conYearlyComplRqst = 6
strControl = ""
If Me!Frame0.Value <> conWeeklyComplRqst <> conMonthlyComplRqst <>
conYearlyComplRqst Then
If IsDate(txtBeginDate) And IsDate(txtEndDate) Then
If CDate(txtEndDate) < CDate(txtBeginDate) Then
MsgBox "The ending date must be later than the beginning
date."
txtEndDate.SetFocus
Exit Sub
End If
Else
'MsgBox "Use valid dates for the beginning and ending date
values."
strControl = strControl & "Use valid date values for beginning
and ending" & vbCrLf
'Exit Sub
End If
End If
Select Case Me!Frame0
Case 1
DoCmd.OpenReport "New Requests", PrintMode
Case 2
DoCmd.OpenReport "Completed Requests", PrintMode
Case 3
DoCmd.OpenForm "Weekly Report", acNormal
Case 4
DoCmd.OpenReport "Monthly Report", PrintMode
Case 5
DoCmd.OpenReport "Status Report", PrintMode
Case 6
DoCmd.OpenReport "Year To Date", PrintMode
Case 7
DoCmd.OpenReport "Outstanding Report", PrintMode
End Select
If strControl <> "" Then
MsgBox "Following information required:" & vbCrLf & strControl,
vbInformation, "Incomplete Information"
End If
Exit_Preview_Click:
Exit Sub
Err_Preview_Click:
Resume Exit_Preview_Click
End Sub
Private Sub Preview_Click()
' Preview selected report. This procedure uses the PrintReports
' Sub procedure defined in (General) section of this module.
PrintReports acPreview
End Sub