Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2004
    Posts
    139

    Unanswered: On No Data event - Stop Macro in VBA???

    I have a macro that has another macro embedded to print preview a report. On this print macro, I need the print macro to stop if there is no data in the report. I have placed a stop macro in the On No Data event but it only stops the stop macro not the print macro. So I am thinking that I need to put some code in the On No Data event to stop the print macro which would allow it to go back to the original macro and finish. I am no VBA programmer so I am asking for the assistance of somebody in the know!

    I appreciate any assistance you can provide!!

    Thanks,
    B&R

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi

    I received your email from ages ago only today (I don't use that account much...) - if you need to contact me best to PM me Anyway - wasn't ignoring you.

    I generally handle this with some code in the report open event. Check the Me.HasData property. If it returns false then set a public property (e.g. called Quit) for the form (or a global variable if that sounds galling) to True. Have the calling code check the property\ variable after opening the report and kill it if there is no data. Reason I do it this way is that setting the OnOpen argument Cancel to true results in a error in the calling procedure.

    I would love to hear a more elegant solution though.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Feb 2004
    Posts
    139

    pootle plump

    I have already sent you a private message.
    Attached Files Attached Files

  4. #4
    Join Date
    Feb 2002
    Posts
    108
    I have several reports like this also, but I use the
    If Dcount("RecordID","SalesOrders","[InvoiceTotal]>='1000'")=0 then
    response=msgbox("No records found", vbOKOnly + vbExclamation,"No Records Found")
    exit sub
    end if
    just before the call to open the report to tell me there are no records and then exit sub

  5. #5
    Join Date
    Feb 2004
    Posts
    139
    WOW, what a great idea. I took your suggestion and placed it as a condition in my macro. So it checks for any records in the table and only runs the macro is there are rows in the table.

    Great suggestion.

    Thanks again,
    B&R

Posting Permissions

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