1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Access: Close Report without Saving

Discussion in 'Business Applications' started by JF Sly, Apr 15, 2004.

Thread Status:
Not open for further replies.
Advertisement
  1. JF Sly

    JF Sly Thread Starter

    Joined:
    Apr 6, 2004
    Messages:
    11
    How can I (Through VBA) close a report automatically without prompting the user to save changes and NOT save any changes?

    I have tried the following in the on close event:

    DoCmd.close acReport, ReportName, acSaveNo

    me.dirty = False

    Neither work.
     
  2. MustBNuts

    MustBNuts

    Joined:
    Aug 21, 2003
    Messages:
    2,016
    I'm not clear why a user is getting that for a report...they shouldn't be if they are just accessing the report and not the report design....

    are you sure about this?

    MBN
     
  3. JF Sly

    JF Sly Thread Starter

    Joined:
    Apr 6, 2004
    Messages:
    11
    The report is modified on the fly (it gets modified in design mode dynamically) then after the modification is made, changes to preview mode for the user to review/print. After the user is done printing/reviewing the report, I do not want the changes saved nor prompt the user to save (so they do not accidently say "yes")
     
  4. MustBNuts

    MustBNuts

    Joined:
    Aug 21, 2003
    Messages:
    2,016
    Okay, that makes more sense. How well do you know VBA? Have you tried stepping through the code to determine exactly where that prompt is being fired?

    I'll take a look at one of my dbases and see what I can come up with....

    MBN
     
  5. JF Sly

    JF Sly Thread Starter

    Joined:
    Apr 6, 2004
    Messages:
    11
    I tried to put code in both the on Close event and in the On Deactivate event. However the prompt comes up prior to hitting either of those events. (I put code in for a msgbox to see when it was at that step and neither fired until after the prompt for save.

    I tried to use DoCmd.SetWarnings False

    While this turned off the prompt (good thing), it automatically saved the report (Bad Thing).
     
  6. MustBNuts

    MustBNuts

    Joined:
    Aug 21, 2003
    Messages:
    2,016
    I tried every which way to achieve this, but no go. Seems Access locks you out of its "Close" process...you have access to a Deactivate, Unload, and Close, but the prompt to save is firing before these....????

    MBN
     
  7. JF Sly

    JF Sly Thread Starter

    Joined:
    Apr 6, 2004
    Messages:
    11
    Yes, I tried putting my vba in all of those areas with no luck. Is there a way to maybe change the default answer of the yes/No/cancel to be No. If so, then I can just set warnings false and the default of No would keep it from saving the report?????
     
  8. MustBNuts

    MustBNuts

    Joined:
    Aug 21, 2003
    Messages:
    2,016
    quick question for you: what is changing in the report? I have reports that have appearing/disappearing fields, but no prompts after I run it...also, where is the code that determines this? In the report design/vba?

    MBN
     
  9. JF Sly

    JF Sly Thread Starter

    Joined:
    Apr 6, 2004
    Messages:
    11
    Fields (bound text boxes) are added to the detail section. Becasue the fields come from a crosstab query, not all the fields are the same each time (some are, but those are already on the report). The fields that change, are the fields that are added dynamically. The vba code is actually in the "on Click" event of a command button on a form where the user selects a parameter for the query. The button opens the report in design view and then adds the extra fields to the report. Also adds associated Labels in the header section.
     
  10. MustBNuts

    MustBNuts

    Joined:
    Aug 21, 2003
    Messages:
    2,016
    Okay, based on this, the only thing I can think of to possibly avoid the prompt is to avoid dynamically changing the report.

    Another possible option is to create the report with all of your parameter fields placed on the report but set to visible=false. Then, in the click event, pass the parameters but using vba, for each existing parameter the visible property would change to true.

    With any luck, the format of the report will allow this. And, I believe, if only the visible property is changing, the system will not consider it a "dirty" report, thus no save prompt.

    Hope this helps,

    MBN
     
  11. JF Sly

    JF Sly Thread Starter

    Joined:
    Apr 6, 2004
    Messages:
    11
    The problem is, that the control source for the additional controls will change depending on the results of the crosstab query. Wouldn't changing the controlSoruce make it "dirty"?
     
  12. MustBNuts

    MustBNuts

    Joined:
    Aug 21, 2003
    Messages:
    2,016
    I see your point....

    What I am thinking is that (via vba code) if you populate your report with all the possible fields, set them to visible=false, then in the load detail in code you could program it to determine if the field exists then show and populate...but then it might error out on a non-existent field...don't know as I've never tried.

    when all is said and done, it may just end up easier to train your users to hit No when closing....

    MBN
     
  13. JF Sly

    JF Sly Thread Starter

    Joined:
    Apr 6, 2004
    Messages:
    11
    Tried this weekend, still prompts the user to save when changing from not visable to visable. Soooo, guess the user will just have to get in the habit of answering NO
     
  14. MustBNuts

    MustBNuts

    Joined:
    Aug 21, 2003
    Messages:
    2,016
    Well, it's not like you didn't try! :)

    MBN
     
  15. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/220868

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice