It says "Sorry! No records were found with the result you have selected" but it then opens an empty report anyway. How can I fix that?
This is my code:
Public Function DisplayResult(VarResultVal) As String
'converting Option group values from integer to string value
On Error GoTo Err_Function
Const conErrorNullField = 3021
Select Case VarResultVal
Case Is = 1
DisplayResult = "No record"
Case Is = 2
DisplayResult = "No further action"
Case Is = 3
DisplayResult = "Final set not accepted"
Case Is = 4
DisplayResult = "Response required "
End Select
Err_Function:
If Err.Number = conErrorNullField Then
MsgBox ("Sorry! No records were found with the result you have selected"
End If
End Function
-------------------------
Private Sub cmdViewReport_Click()
Dim strName As String
Dim strDocName As String
strName = Me.cboMgr
strDocName = "rptMgr"
dteValFrom = Me.txtFrom
dteValTo = Me.txtTo
If strName = "All Mgr" Then
DoCmd.OpenReport strDocName, acPreview, , "[RecordCreationDate] Between (#" & dteValFrom & "#) and (#" & dteValTo & "#)"
Else
DoCmd.OpenReport strDocName, acPreview, , "Mgr= '" & strName & " ' and [RecordCreationDate] Between (#" & dteValFrom & "#) and (#" & dteValTo & "#)"
End If
End Sub
This is my code:
Public Function DisplayResult(VarResultVal) As String
'converting Option group values from integer to string value
On Error GoTo Err_Function
Const conErrorNullField = 3021
Select Case VarResultVal
Case Is = 1
DisplayResult = "No record"
Case Is = 2
DisplayResult = "No further action"
Case Is = 3
DisplayResult = "Final set not accepted"
Case Is = 4
DisplayResult = "Response required "
End Select
Err_Function:
If Err.Number = conErrorNullField Then
MsgBox ("Sorry! No records were found with the result you have selected"
End If
End Function
-------------------------
Private Sub cmdViewReport_Click()
Dim strName As String
Dim strDocName As String
strName = Me.cboMgr
strDocName = "rptMgr"
dteValFrom = Me.txtFrom
dteValTo = Me.txtTo
If strName = "All Mgr" Then
DoCmd.OpenReport strDocName, acPreview, , "[RecordCreationDate] Between (#" & dteValFrom & "#) and (#" & dteValTo & "#)"
Else
DoCmd.OpenReport strDocName, acPreview, , "Mgr= '" & strName & " ' and [RecordCreationDate] Between (#" & dteValFrom & "#) and (#" & dteValTo & "#)"
End If
End Sub