Again, I've searched but am limited on time to find the answer. Here is my code.
Private Sub Command12_Click()
On Error GoTo Error_Handler
Dim stUnitName As String
Dim stReportName As String
stUnitName = Me.Admin_Unit.Value
If Not [Admin Unit] = "ALL UNITS" Then
If [Report Name] = "Date Rip Sent Report" Then
DoCmd.OpenReport "Date Rip Sent Report", acViewNormal, , "[Unit Description] = '" & stUnitName & "'"
DoCmd.Maximize
End If
If [Report Name] = "PDD Report" Then
DoCmd.OpenReport "PDD Report", acViewNormal, , "[Unit Description] = '" & stUnitName & "'"
DoCmd.Maximize
End If
If [Report Name] = "Unit Report" Then
DoCmd.OpenReport "Unit Report", acViewNormal, , "[Unit Description] = '" & stUnitName & "'"
DoCmd.Maximize
End If
Else
If [Report Name] = "Date Rip Sent Report" Then
DoCmd.OpenReport "Date Rip Sent Report", acViewNormal
DoCmd.Maximize
End If
If [Report Name] = "PDD Report" Then
DoCmd.OpenReport "PDD Report", acViewNormal
DoCmd.Maximize
End If
If [Report Name] = "Unit Report" Then
DoCmd.OpenReport "Unit Report", acViewNormal
DoCmd.Maximize
End If
End If
Exit_Handler:
Exit Sub
Error_Handler:
If Err.Number = 2501 Then Err.Clear
If Not Err.Number = 2501 Then
If [Report Name] = "" Then
MsgBox "Please select type of report before continuing.", vbOKOnly, _
"Title of Message Box"
End If
If [Admin Unit] = "" Then
MsgBox "Please select Unit before continuing.", vbOKOnly, _
"Title of Message Box"
End If
Resume Exit_Handler:
End If
End Sub
******END CODE*****
The reports won't open, instead they print. The error code doesn't work. When I leave either field blank, it does nothing. What am I doing wrong? I've worked on this for two days with no progress.
Thanks in advance.
Private Sub Command12_Click()
On Error GoTo Error_Handler
Dim stUnitName As String
Dim stReportName As String
stUnitName = Me.Admin_Unit.Value
If Not [Admin Unit] = "ALL UNITS" Then
If [Report Name] = "Date Rip Sent Report" Then
DoCmd.OpenReport "Date Rip Sent Report", acViewNormal, , "[Unit Description] = '" & stUnitName & "'"
DoCmd.Maximize
End If
If [Report Name] = "PDD Report" Then
DoCmd.OpenReport "PDD Report", acViewNormal, , "[Unit Description] = '" & stUnitName & "'"
DoCmd.Maximize
End If
If [Report Name] = "Unit Report" Then
DoCmd.OpenReport "Unit Report", acViewNormal, , "[Unit Description] = '" & stUnitName & "'"
DoCmd.Maximize
End If
Else
If [Report Name] = "Date Rip Sent Report" Then
DoCmd.OpenReport "Date Rip Sent Report", acViewNormal
DoCmd.Maximize
End If
If [Report Name] = "PDD Report" Then
DoCmd.OpenReport "PDD Report", acViewNormal
DoCmd.Maximize
End If
If [Report Name] = "Unit Report" Then
DoCmd.OpenReport "Unit Report", acViewNormal
DoCmd.Maximize
End If
End If
Exit_Handler:
Exit Sub
Error_Handler:
If Err.Number = 2501 Then Err.Clear
If Not Err.Number = 2501 Then
If [Report Name] = "" Then
MsgBox "Please select type of report before continuing.", vbOKOnly, _
"Title of Message Box"
End If
If [Admin Unit] = "" Then
MsgBox "Please select Unit before continuing.", vbOKOnly, _
"Title of Message Box"
End If
Resume Exit_Handler:
End If
End Sub
******END CODE*****
The reports won't open, instead they print. The error code doesn't work. When I leave either field blank, it does nothing. What am I doing wrong? I've worked on this for two days with no progress.
Thanks in advance.