check empty file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mindy

    #1

    check empty file

    Hey,

    I was running a query to automatically send out excel file, which
    including the list of people receiving gifts in 10 days. I wonder if
    there is anyway to check if the excel file is empty before sending the
    file.

    Any suggestions are welcome. Thank you.

    Mindy

  • mksnyder

    #2
    Re: check empty file

    You could use an If...Then...Els e statement (VB Code) and use the
    DCount() function to count the records in the recordset BEFORE you
    export it, and if the count is 0, then pop a message box (MsgBox)
    alerting the user that there are no records, and no file will be
    exported, but if there are records THEN export the file and pop a
    message box telling the user how many records and where the file is
    located. The code to count the recordset and create the Excel file
    (and email it, if that is what you are ultimately trying to do) can all
    be put in the CLICK event of a command button on a form.

    Hope this helps.

    mksnyder

    Comment

    Working...