R
Robert
i have a command button on a form to preview report. i want to have msgbox
when no data in the report and automatically close the report. here are my
codes:
Private Sub cmd201not291_Click()
On Error GoTo Err_cmd201not291_Click
Dim stDocName As String
Select Case Sem
Case 1 'Winter
Select Case Loc
Case 1 'Regular
stDocName = "WI201N291R"
Case 2 'Online
stDocName = "WI201N291O"
Case 3 'South Gate
stDocName = "WI201N291S"
End Select
Case 2 'Spring
Select Case Loc
Case 1 'Regular
stDocName = "SP201N291R"
Case 2 'Online
stDocName = "SP201N291O"
Case 3 'South Gate
stDocName = "SP201N291S"
End Select
Case 3 'Summer
Select Case Loc
Case 1 'Regular
stDocName = "SU201N291R"
Case 2 'Online
stDocName = "SU201N291O"
Case 3 'South Gate
stDocName = "SU201N291S"
End Select
Case 4 'Fall
Select Case Loc
Case 1 'Regular
stDocName = "FA201N291R"
Case 2 'Online
stDocName = "FA201N291O"
Case 3 'South Gate
stDocName = "FA201N291S"
End Select
End Select
DoCmd.OpenReport stDocName, acPreview
Exit_cmd201not291_Click:
Exit Sub
Err_cmd201not291_Click:
MsgBox Err.Description
Resume Exit_cmd201not291_Click
End Sub
when no data in the report and automatically close the report. here are my
codes:
Private Sub cmd201not291_Click()
On Error GoTo Err_cmd201not291_Click
Dim stDocName As String
Select Case Sem
Case 1 'Winter
Select Case Loc
Case 1 'Regular
stDocName = "WI201N291R"
Case 2 'Online
stDocName = "WI201N291O"
Case 3 'South Gate
stDocName = "WI201N291S"
End Select
Case 2 'Spring
Select Case Loc
Case 1 'Regular
stDocName = "SP201N291R"
Case 2 'Online
stDocName = "SP201N291O"
Case 3 'South Gate
stDocName = "SP201N291S"
End Select
Case 3 'Summer
Select Case Loc
Case 1 'Regular
stDocName = "SU201N291R"
Case 2 'Online
stDocName = "SU201N291O"
Case 3 'South Gate
stDocName = "SU201N291S"
End Select
Case 4 'Fall
Select Case Loc
Case 1 'Regular
stDocName = "FA201N291R"
Case 2 'Online
stDocName = "FA201N291O"
Case 3 'South Gate
stDocName = "FA201N291S"
End Select
End Select
DoCmd.OpenReport stDocName, acPreview
Exit_cmd201not291_Click:
Exit Sub
Err_cmd201not291_Click:
MsgBox Err.Description
Resume Exit_cmd201not291_Click
End Sub