Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

undo changes on report

Status
Not open for further replies.

xezekielx

IS-IT--Management
Jun 30, 2005
93
CA
Hi! I have this report that I dynamically add some subreport controls on. Now the problem is that I DON'T want to be prompted to save the report or not when I close it. I want to undo/cancel the changes that I made on it (adding the subreport controls) without the small prompt. Is it possible? Thanks in advance!
 
DoCmd.Close acReport, [blue]"NameOfReport"[/blue], [red]acSaveNo[/red]
 
but what if the user clicks on the 'X' in the top right corner?
 
You could disable the Close button and place your own command button to exit the report.

Ken S.
 
Well I made a toolbar with a "Close" button executing the DoCmd.Close command. The problem is that the report is maximized upon load, and if I click on the X in top right corner, it first asks me whether I want to save the report or not and then MS Access closes... I could always "restore" the report upon load instead of maximizing it, but the thing is that I have a splash screen form that's maximized and it will be restored as well if I restore the report. Any idea how I should proceed to either avoid restoring the splash screen or to close the report without being prompted to save? Thanks a lot for taking the time to help!
 
Make a custom toolbar for your entire db. I do that, call it MAIN and only have one item on it: EXIT (to quit the db). In STARTUP PROPERTIES i disable standard toolbars, and put in MAIN in the drop-down. Then reports don't come up with the x.

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
Thanks for your answer GingerR, but it doesn't seem to work... The X that appears in the top right corner is the one in the app's title bar, not in the report's title bar because the report is maximized when it's opened. I don't think that this X can be disabled (well maybe with API calls but anyway)...
 
Oh, i thought you meant the REPORT x.

Try this: on your code, declare some public variable at the top of the code sheet, like

Dim ClosedByButton as boolean
ClosedByButton = False

Then in your toolbar custom button, add to the code:

ClosedByButton = true

Then in the report's OnClose event, put

If not(ClosedByButton) then cancel = true
'Reset ClosedByButton
ClosedByButton = False

try something like that...

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
Wow! That's a good idea! But how do you cancel the OnClose event of a report? There's no 'Cancel' parameter...
 
oh. i'm an idiot. let me poke around a bit--i know i've seen someone talk about this kind of thing with forms before...

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
here you go--try this.

thread703-822182

sorry for the reply earlier, i should have tried it out first.


Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
Thanks! Now... the report won't close if I click the X BUT it still asks me whether I want to save the changes or not...
 
Still asks the question if you hit the "x"? Or if you choose the custom toolbar button you made?

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
If I click the X. In the code for the button, I used the following code:

DoCmd.Close acReport, "rptFinal", acSaveNo

It closes the report without prompting to save. I want to have the same effect when I click the X.
 
hmmm..worked ok for me. it didn't ask the question and the report just sat there in design mode (i'd moved a text box) and the form (not hidden in my case) just sits there too.

What is the code in your hidden form's OnOpen and OnUnload events?

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
in the form's OnOpen event:
Code:
gblnCanClose = True

in the form's OnUnload event (this form's like a kind of splash screen):
Code:
    If gblnCanClose = True Then
        Dim mbrChoice As VbMsgBoxResult

        mbrChoice = MsgBox("Do you really want to quit ?", vbYesNo + vbDefaultButton2 + vbQuestion)
        If mbrChoice = vbNo Then
            Cancel = True
        Else
            'Close the app completely
            DoCmd.Quit
        End If
    Else
        Cancel = True
    End If

in the report's OnOpen event:
Code:
gblnCanClose = False

in the button's OnClick event:
Code:
DoCmd.Close acReport, "rptFinal", acSaveNo
gblnCanClose = True

I just go an idea... maybe I could save the changes made on the report but when I generate a new one, I delete the controls that I previously added and re-add those that need to be added. But is there a command to save the changes made on the report (apart from DoCmd.Close [...], acSaveYes)? The DoCmd.Save command doesn't seem to work
 
OnOpen of the form, set the variable to FALSE
Only set it to true when the user clicks the correct button

one problem to watch out for: as i'm playing with this, i now can't close access at all--stuck with the 'hidden' form open forever...

anyhow, i'll have to play more tomorrow...


Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
problem solved! before re-opening the report with the acPreview parameter, I just close it with the acSaveYes. then at the beginning of my function to generate the report, I loope through the Controls collection and delete the undesired controls. Thanks a lot for helping me GingerR! I really appreciate it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top