Results 1 to 3 of 3
  1. #1
    rhernand
    Guest

    Macro Conditions (Access 97)

    I am running a Report based on a table created by a Make Table Query. Sometimes the table may be empty, because no solution set was found. I am getting errors on the Report. I am running the query and report from a Macro, how can I check on the Conditions that the table is emply and run another Report advising that no data was found?

  2. #2
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Altnau, Thurgau, Switzerland
    Posts
    447
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro Conditions (Access 97)

    By MACRO do you mean a macro or a VBA function?

    There is a report event 'NoData'. You could display a message there if that was enough.

    If you do require another report then check if the table has any records and then display the appropriate report.

    eg.
    DIM RS as Recordset, DB as Database
    Set DB = CurrentDB
    Set RS = DB.Open("SELECT * FROM <mytablename>")
    if RS.Recordcount > 0 then
    'table has records
    else
    'Table is empty
    end if
    set RS = nothing
    Set DB = nothing

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Macro Conditions (Access 97)

    In your first report's NoData event, you can place a macro or code to open that 2nd report. I use a macro I call Empty Report, whose first Action pops a message box saying "Your selections produced an empy report!", and the 2nd Action is a CancelEvent.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

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