Closing Access While Form Is In Print Preview Does Not Trigger Form Unload Event

We use the form unload event of our main form to make sure the user exist
through our exit process instead of just closing access with the top right X
on the access application.  This works if the form is in form view.

However, if the user uses the Office button to do a Print\Preview and then
clicks on the top right X on the access application access closes without
triggering the form unload event.

Is this by design or a bug?  Is there away around this behavior?  Is there a
way to prevent a form from going into print preview mode while still
allowing the use of the Office button Print\Preview for reports?

0
Stewart
6/4/2010 10:30:53 PM
access.formscoding 7494 articles. 0 followers. Follow

3 Replies
1050 Views

Similar Articles

[PageSpeed] 0

I use this sort of thing on the unload event of a form that is always open 
and hidden.

Private Sub Form_Unload(Cancel As Integer)
'if user has report open, gives chance to say no
'if they clicked the main app X by mistake
'and runs the quit actions code before access closes

    'Debug.Print Reports.Count
    If Reports.count > 0 Then
        If vbCancel = MsgBox("Are you sure you want to close the 
database?", vbOKCancel, Close?) Then
            Cancel = True
       Else
            'code here to call the exit routine
        End If
    End If
End Sub

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

"Stewart Berman" <saberman@nospam.nospam> wrote in message 
news:1kvi0655kbngmk6jdqoo0i88l00vpvjooh@4ax.com...
> We use the form unload event of our main form to make sure the user exist
> through our exit process instead of just closing access with the top right 
> X
> on the access application.  This works if the form is in form view.
>
> However, if the user uses the Office button to do a Print\Preview and then
> clicks on the top right X on the access application access closes without
> triggering the form unload event.
>
> Is this by design or a bug?  Is there away around this behavior?  Is there 
> a
> way to prevent a form from going into print preview mode while still
> allowing the use of the Office button Print\Preview for reports?
> 


0
Jeanette
6/5/2010 10:55:44 PM
We original tried that but the main form has to do a good deal of cleanup
before closing and there was no way to stop it from being closed before the
form unload event in the invisible form is invoked.  Once application close
is invoked by clicking on the X there is no guarantee as to the order access
will close open objects.

"Jeanette Cunningham" <nnn@discussions.microsoft.com> wrote:

>I use this sort of thing on the unload event of a form that is always open 
>and hidden.
>
>Private Sub Form_Unload(Cancel As Integer)
>'if user has report open, gives chance to say no
>'if they clicked the main app X by mistake
>'and runs the quit actions code before access closes
>
>    'Debug.Print Reports.Count
>    If Reports.count > 0 Then
>        If vbCancel = MsgBox("Are you sure you want to close the 
>database?", vbOKCancel, Close?) Then
>            Cancel = True
>       Else
>            'code here to call the exit routine
>        End If
>    End If
>End Sub
>
>Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
>
>"Stewart Berman" <saberman@nospam.nospam> wrote in message 
>news:1kvi0655kbngmk6jdqoo0i88l00vpvjooh@4ax.com...
>> We use the form unload event of our main form to make sure the user exist
>> through our exit process instead of just closing access with the top right 
>> X
>> on the access application.  This works if the form is in form view.
>>
>> However, if the user uses the Office button to do a Print\Preview and then
>> clicks on the top right X on the access application access closes without
>> triggering the form unload event.
>>
>> Is this by design or a bug?  Is there away around this behavior?  Is there 
>> a
>> way to prevent a form from going into print preview mode while still
>> allowing the use of the Office button Print\Preview for reports?
>> 
>
0
Stewart
6/6/2010 10:57:47 PM
Yes there is, access closes down forms in order.
The first opened form (of the forms that are still open) is the last one to 
be closed.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

"Stewart Berman" <saberman@nospam.nospam> wrote in message 
news:sk9o061oe3dm665mfrqjvtgfcbo4k299sh@4ax.com...
> We original tried that but the main form has to do a good deal of cleanup
> before closing and there was no way to stop it from being closed before 
> the
> form unload event in the invisible form is invoked.  Once application 
> close
> is invoked by clicking on the X there is no guarantee as to the order 
> access
> will close open objects.
>
> "Jeanette Cunningham" <nnn@discussions.microsoft.com> wrote:
>
>>I use this sort of thing on the unload event of a form that is always open
>>and hidden.
>>
>>Private Sub Form_Unload(Cancel As Integer)
>>'if user has report open, gives chance to say no
>>'if they clicked the main app X by mistake
>>'and runs the quit actions code before access closes
>>
>>    'Debug.Print Reports.Count
>>    If Reports.count > 0 Then
>>        If vbCancel = MsgBox("Are you sure you want to close the
>>database?", vbOKCancel, Close?) Then
>>            Cancel = True
>>       Else
>>            'code here to call the exit routine
>>        End If
>>    End If
>>End Sub
>>
>>Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
>>
>>"Stewart Berman" <saberman@nospam.nospam> wrote in message
>>news:1kvi0655kbngmk6jdqoo0i88l00vpvjooh@4ax.com...
>>> We use the form unload event of our main form to make sure the user 
>>> exist
>>> through our exit process instead of just closing access with the top 
>>> right
>>> X
>>> on the access application.  This works if the form is in form view.
>>>
>>> However, if the user uses the Office button to do a Print\Preview and 
>>> then
>>> clicks on the top right X on the access application access closes 
>>> without
>>> triggering the form unload event.
>>>
>>> Is this by design or a bug?  Is there away around this behavior?  Is 
>>> there
>>> a
>>> way to prevent a form from going into print preview mode while still
>>> allowing the use of the Office button Print\Preview for reports?
>>>
>> 


0
Jeanette
6/7/2010 2:15:39 AM
Reply:

Similar Artilces:

Extra pages printing
My report is printing additional pages? The report is created from a query, the query has a few tables with joins, nothing fancy. When the report is run is gives me: A. monthly totals "=Count(IIf(Month([IssueCloseDate])=1,1,Null)) B. =Sum(Abs([Days]<30........ C. =IIf([Text58]=0,0,[Text45]/[Text58]) Nothing too fancy again.. For some reason if the person had a total of 10 it returns 10 pages. I only want 1 page showing a total of 10 (each page does say 10 but prints 10 pages)... The sorting/grouping is only by person grouped on each value.. Please help - I've spent way too mu...

remove access w2k8 server with server manager
in w2k3 I can access remote servers using Computer Management, to view logs, share and local groups/users. In w2k8 Server Manager I can't find a way to connect to a remote server. Am I missig something or there is a different way to do so? Thanks. You are not missing anything. Server Manager added this support in 2008 R2 but 2008 can only view local roles and features. You can launch mmc and the snapins you want for the remote machine. -- Alan Morris Windows Printing Team Search the Microsoft Knowledge Base here: http://support.microsoft.com/search/?adv=1 This...

Outlook Web Access #21
Can I check my Outlook Web Access account using Outlook 2002? My office is not using a Microsoft Exchange Server. ...

Urgent help: change outlook default conatct form
Hi all, We added several fields to contacts in the standard form (design mode). We want this form to become users' default conatct form. Also, old contacts are able to launch from this new customized form. are these possible? exchange 2003/outllokk2003/outlook 2007) Yes. This is possible. You need to change the form on the folder properties and then run a program to change the IPM form used on existing items. See the last two sections at http://www.outlook-tips.net/beginner/publish_form.htm for details and link to the program. -- Diane Poremsky [MVP - Outlook] ...

Problems with MS Access reading dates as US, not British formats.
Hi Folks, I downloaded a database off the MSDN website (web address:http://msdn.microsoft.com/en-us/library/dd327646.aspx). It calculates the number of working days and takes off any holidays which are stored in a separate table. It works fine, but the only problem is that when I enter dates in the holiday table, it reads it as the US format of m/d/yy instead of UK d/m/yy. I have set the regional settings to UK time/date so my dates in the Holidays table are displayed as UK, but I have to remember to enter the dates in US order, for the system to work. (I know this wil...

ThisWorkbook.Close question
Please take a look at the code below: Public Sub DumbFoo ( ) ThisWorkbook.Close() Sheet1.Range("A1").Value = -1 ThisWorkbook.Save() End Sub Is it safe to assume that the code below the "ThisWorkbook.Close()" line will NOT be executed??? My question is basically: Does all VBA code stop executing once a .Close() function is called??? Thank you! I don't believe the code would execute at all because of the parentheses after Close. It would throw an error an tell you that something is missing, or type mismatch. But, if you did...

How to Enable Close(cross) button of MB_YESNO messagebox
Hi, I want to enable the close(cross) button in the right corner of YESNO message box. Can anybody tell me how to do this. Klic. "Klic" <rohit.turambekar@gmail.com> wrote in message news:1186120969.045121.287770@i13g2000prf.googlegroups.com... > I want to enable the close(cross) button in the right corner of YESNO > message box. > Can anybody tell me how to do this. Why? If there is a valid answer other than yes or no, then how about a yes/no/cancel message box in which (I would guess) the x button is equivalent to cancel. That would be more standard. Da...

Access 2000 run on XP
Will access 2000 run on XP? Dennis access 97, access 95, and even access 2.0 from the early 90's will run. In fact, you can run dos based FoxPro stuff, or even the original pc spreadsheet that came out in 1981 (that is not a misprint!!). so, yes, office 2000 will win on windows 98, 2000, xp, and also vista.... -- Albert D. Kallal (Access MVP) Edmonton, Alberta Canada pleaseNOOSpamKallal@msn.com ...

How do I print a one page spreadsheet multiple time, each with its own page number?
Hello: I have a one page spreadsheet, essentially a template. I would like t be able to print as many copies as needed, but each copy has to print unique sequence value, which increments by one every time it i printed. This variable may require some formatting, but it's somewhat like page number. Printing multiple copies is just reprinting page one t Excel; each page is labeled 1. I'd rather not copy my print range number of times into the workbook, but that's what I did, just to ge started. I don't have any VB experience; I was just trying to us Excel's existing ...

RDA (remote data access)
how can i write or read data from pervasive sql on the server? this is what i now have: // The local connection string. private string strConnLocal = "Data Source =" + System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingA ssembly().GetName().CodeBase) + "\\test.sdf;"; // The remote connection string. private string strConnRemote = "Provider=sqloledb; " + "Data Source=test; " + "Initial Cat...

Outlook closes and closes
Hi I have a strange bug. Windows XP Sp2 and outlook from office 20003 with all service packs applied. When I start outlook from windows out of standby postion, outlook immediately after the splash screen closes without reporting any errors in the eventlog or in any other log. If I start outlook the 10th time (or so) it stabilizes and does not close anymore and everything works again. info: My machine is fully patched and I am well known with keeping things healthy. Outlook.exe Version: 11.0.6353.0 Any ideas what to do? Thanks... try the detect and repair in the help menu. >----...

closing
What's the best way to close for the day? Making a backup is a given, but what about the computer? Is it better to shut everything off every day, or is it less wear and tear on the computer to leave it on all the time? Any thoughts on this would be appreciated. Craig That's a matter of preference really. Personally I always turn off my rigs at home when I'm done with them. At the store we leave most of ours on 24/7. We've done it for years with no issues. Our register must be left on as it does automatic backups to a tape drive every night. I'd set your monitors ...

Help
When creating or fowarding an e-mail message using outlook 2000, scrolling through my "recipients" list (contacts) causes the program to close unexpectedly. So, I click "new", click "to", switch to my "contacts" list, and as I scroll through the names, the program just closes. Is there a possibility that one of my contact records is corrupt? I have opened all of my contacts and saved them without an error. This problem developed shortly after the install of Office 2000's calender update, and basic security update. I have since fully u...

Outlook Web Access #9
Hi, I'm running 2 Exchange 5.5 servers, one on a W2k box, one on a NT4 box. I just installed OWA onto a third server, which is W2k, and is running IIS. I only installed OWA, nothing else. I upgraded it to SP4, same as the 2 mail servers. Question is - where do I go from here?! I can't see anywhere on the IIS server to configure. Should I have installed Exchange admin onto the server as well as OWA? Is the configuration and set up done at the email server? Thanks in advance Steve http://support.microsoft.com/default.aspx?scid=kb;en-us;234805 On Wed, 19 May 2004 00:17:04 +010...

Excel Form and message box
Hi there, I'm running Excel 2000. I am just learning so please excuse my questions if they sound simple. To put this as simply as possible I have a spreadsheet of children's names. I've created a form that is activated by a control button. What I want to do is choose a child's name from the combo box and eventually delete that child from the spreadsheet. I have an "are you sure" type msgbox but cannot get the yes/no side of it functioning correctly. I've worked on this for hours and have just given up. This is my code so far: Private Sub cboRemChild_...

Updating a form if field has been removed so that I don't get a me
Hi I have created a form. Due to modifications to the form, I no longer need a field which I have included in the original form. Before I deleted the field, I had made a back up of my database. When I delete the field, let's call it "ProductCodeOld", whenever I open up the database, I get a text box saying that the "ProductCodeOld" is not in the form or words to that effect. How do I remove a field from a form without this type of message appearing? Thank you in advance. Forest8 - You may have code in the form that references the old field. ...

Why does doc. in Pub. jump from landscape to portrait when print?
When we create a wide document in Publisher 2003 and want to print it out on Ledger size paper, the document appears fine on the screen, but when you click "print", on the screen, the "paper" on the screen jumps from ledger to portrait, leaving the content off the page, and it prints wrong (off the page). One trick that works sometimes, is to go Page Setup and change paper size from ledger to legal, then back to ledger. Then, change the setting from Landscape to Portrait, then back to Landscape. This will put the document back correctly on the screen, but when y...

Opening up Access in Form View
I have created a form in Acces that is a main menu. When I click on the database icon I want the database to open in the main menu form. How do I do that? Thank you! For pre-2007 versions select Tools | Startup on the main database menu bar, and then select the relevant form as the Display Form/Page property. I can't speak for 2007, but I imagine it will be broadly similar. Ken Sheridan Stafford, England Alaska1 wrote: >I have created a form in Acces that is a main menu. When I click on the >database icon I want the database to open in the main menu form. Ho...

Workflow Rule -> Closing Activity
I set up a Manual Workflow Rule for Contacts to close out Holiday Season cards sent. The rule uses a condition to check for Contacts with cards sent and then Creates an Activity to add to each of the appropriate Contacts for future reference. What else do I need to do to close out all of activites rather than 1 at a time? Here is the workflow rule if that helps: if Contact.holidaycardlist = 1 then Letter: Send Holiday Card endif -- Dan W Systems Engineer Denver, CO ...

Auto-close Quotes when Closing Opportunity
We would like the ability to close an opportunity and have it ask if you want to close all the associated quotes. Right now, it says you can’t close the opp until you close all the open quotes and you have to each one of those one by one. Barring that, if we could select multiple quotes and click on a menu item (Close all selected quotes), that would be most useful. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not ...

Data file not closed properly #3
I saw several post regarding this, but none had any answers, so I starting a new post. There is also nothing in the KB about this. Since othe people are having the same problem Microsoft should take a look at it. I get the message "The data file 'Personal Folders" was not closed properly" every time I close Outlook 2003. It runs a quick check/fix and starts up fine. I am running XP pro w/ SP-2. Outlook 2003 w/ SP-1 All patches and updates are current. My notebook was just rebuilt for so I could get a clean slate for the office 2003 install, (reformat drive and new ins...

printing using avery paper
I am trying to print business cards on avery business card paper #8876. I cannot find a place to choose a specific avery paper so I did page set up and changed the vertical and horizontal gaps to zero and adjusted the card to its appropriate size. The problem i have run into is that as it prints my header gets closer and closer to the top edge of my cards. It shouldn't be a printer issue as the printer is brand new as of june 28th. Any suggestions? Free software that makes the production of business cards a breeze.. http://www.avery.com/us/Main?action=software.AverySoftwareDetai...

Do you need Access to use an Access Database for data entry only?
We have an Access database completed. Now we will use it for reading as well as for data entry. Do we need to install Access for every workstation needing the database for data entry or reading? No you don't necessarily need Access on every computer. You CAN use the Access Runtime and if it is in Access 2007 you can use it for free. If you are using another version then you would need to purchase the developer's edition to be able to legally distribute the associated Access runtime. If you do have 2007 and want to use the runtime, make sure your Full version of Access doe...

How can I select to print on 11 x 17 paper? It is not an option .
in the dropdown formfield. Mary, File | Page Setup Look for an Options button. You can control page size from there. tj "Mary" wrote: > in the dropdown formfield. TJ, I already did try to customize using File, Page Setup, Options. I do not see 11x 17 anywhere. Nor do I see a place to input these dimensions. Could you please give me a full path? Perhaps I'm missing something here. Mary "Mary" wrote: > in the dropdown formfield. Check your printer setup. Can you print on 11x17 from Word or another program? >-----Original Message----- >TJ,...

Exchange web-access
I've got a exchange 2003 server running at my company. Users can access their mailbox from home or from any computer with internet access. The problem is that the data goes over a non-secure line. Just http. How can I change that to HTTPS?? Greetz Sven "Sven" <Sven@discussions.microsoft.com> wrote in message news:CD5AB8E5-A905-45B5-A7E8-D7DA757A2CE2@microsoft.com... > I've got a exchange 2003 server running at my company. Users can access their > mailbox from home or from any computer with internet access. The problem is > that the data goes over a non-sec...