Advertisement

08.09.2005 at 06:37AM PDT, ID: 21520695
[x]
Attachment Details

Report yeilds #Error when no records exist

Asked by tthayer in Microsoft Access Database

Tags: report, error, records

I have a form called frmOccurrence(This form stays open when the other form is clicked) in which I have a button that opens a form called frmSelectOccurrenceEmployee in which I capture the field called cboEmployee a beginning date called txtbegdate and an ending date called txtenddate.  These fields are used in a query to produce a report showing information based on the employee and date rage selected.  The query is based on a table called tblOccurrence and the fields are called Employee and OccurrenceDate that I am pointing to in my query

This code works and produces a report but when no records are found for the employee and date range selected the report shows #Error.  I would like a way to find out if records do not exist and either show on the report no records found instead of #Error or pop a message and do not run the report.  I prefer the first option if possible.

Below is the code I have been working on which does not work but maybe can be tweaked.  If not I will gladly start over.

Private Sub OK_Click()
On Error GoTo OK_Click_Err
    Dim stDocName As String
    Dim stLinkCriteria As String
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[Employee] = '" & Me![cboEmployee] & "'"
    Me.Bookmark = rs.Bookmark
    stDocName = "frmOccurrence"
    stLinkCriteria = "[EMPLOYEE]=" & "'" & Me![Employee] & "'"
   
   
    If rs.NoMatch Then
        MsgBox "No Records Found"
        Exit Sub
   
    Else
    DoCmd.OpenReport "Employee Occurrence Summary", acViewPreview, "", "", acNormal
    DoCmd.Close acForm, "frmSelectOccurrenceEmployee"
    DoCmd.Maximize
    Beep
    MsgBox "Only Active Employees Displayed", vbInformation, "Information"
    Beep
    MsgBox "To Print Press (CTRL + P)", vbInformation, "Information"
       
    End If
   
OK_Click_Exit:
    Exit Sub

OK_Click_Err:
    MsgBox Error$
    Resume OK_Click_Exit

End Sub
Start Free Trial
[+][-]08.09.2005 at 06:41AM PDT, ID: 14632397

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.09.2005 at 06:42AM PDT, ID: 14632405

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.09.2005 at 06:42AM PDT, ID: 14632408

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.09.2005 at 06:43AM PDT, ID: 14632414

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.09.2005 at 07:26AM PDT, ID: 14632879

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.09.2005 at 07:30AM PDT, ID: 14632921

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Access Database
Tags: report, error, records
Sign Up Now!
Solution Provided By: RDWaibel
Participating Experts: 2
Solution Grade: A
 
 
[+][-]08.09.2005 at 07:43AM PDT, ID: 14633061

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.09.2005 at 08:06AM PDT, ID: 14633297

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32