Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error in Report Results...How to Display MsgBox Instead

Status
Not open for further replies.

kmkland

Technical User
Dec 15, 2004
114
US
I need to produce rptOccurCode from frmParameters having combo box cboAbsenceCode. The user selects a code from the combo box and produces the report. This works fine, however, if there are no results to show, I would like a MsgBox to display to notify the user that no results were found, and no report will be produced.
I am slowly learning VB, but here is what I currently have:
Code:
Private Sub Ok_Click()

    If IsNull(Me.StartDate) And IsNull(Me.EndDate) And IsNull(Me.cboAbsenceCode) Then
        MsgBox "You must first select an Absence Code and  " _
        & vbCrLf & "enter the Start Date and End Date to preview the report. "
            GoTo Exit_OK_Click
    End If
    
    If Not IsNull(Me.cboAbsenceCode) Then
        DoCmd.OpenReport "rptOccurCode", acViewPreview
        GoTo Exit_OK_Click
    End If
    
     If rstOrd.RecordCount = 0 Then
     MsgBox "There are no Occurrences to Print ", vbOKOnly, " frmParameters "
     GoTo Exit_OK_Click
    
    End If
       
     
Exit_OK_Click:
     Me.cboAbsenceCode.SetFocus     
     Exit Sub
    
End Sub

Any thoughts on what I need to do/change?????

Thanks soooo much!
KMK
 
Looks like Access VBA to me - try forum705

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top