Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Location
    Barbados
    Posts
    50

    Unanswered: Generating a msg box for empty reports

    Hi,
    I was wondering if there was a certain code for creating a msg box to pop up if a report doesn't have any information in it? The report is being opened by a command button. And the report is based on a query.


    BajanElf
    "The extreme always make an impression." - Jeff Hardy

  2. #2
    Join Date
    Dec 2003
    Posts
    268

    No Records

    ON the click event for the command button you can do a check to see if there is any records.



    if dlookup("count[fieldname]","[tablename]","criteria") <1 then
    msgbox "No records found"
    exit sub
    else
    docmd.openreport "ReportName"
    end if

  3. #3
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183

    Re: No Records

    Originally posted by mjweyland
    ON the click event for the command button you can do a check to see if there is any records.



    if dlookup("count[fieldname]","[tablename]","criteria") <1 then
    msgbox "No records found"
    exit sub
    else
    docmd.openreport "ReportName"
    end if
    Put this code in report NoData event

    Private Sub Report_NoData(Cancel As Integer)
    MsgBox "No data was found for the report." + _
    "The report will not open.", vbInformation + vbOKOnly
    Cancel = True
    End Sub
    Skharva

  4. #4
    Join Date
    Feb 2004
    Location
    Barbados
    Posts
    50
    Hi,

    Ok wait, I think i see my problem. the code you gave was giving a syntax error. i changed the neccessary information and placed the name of the query the report was getting its data from.

    The thing is I had to do over the forms and there should be an option box in the same form, but now i forgot to put it back in. One of the fields was using code that calculated a due date if the user selected one of the two options.

    so basically your code could be working, but it was my mistake for not checking the dbase more thoroughly.

    bajan_elf
    "The extreme always make an impression." - Jeff Hardy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •