OnClose Event And Exit / Quit Buttons

Jul 24, 2012

I have a form (menu) that auto-loads along w/ the database that has a standard exit button at the bottom. On that form/menu, one item/button loads a table for editing (we'll call this 'edit table' button). I want a prompt to pop up asking whether or not the user would like to export the table to excel on exit, only when a user loads the table, regardless of whether other items from the menu are loaded during the session.

As of right now, I have a hidden form that loads when the 'edit table' button is clicked and I have an OnUnload event set on the hidden form to load an 'export to excel' form/prompt (loaded as dialog, form set to popup & modal). When I test this out by closing the hidden form (clicking it's 'x', or the 'exit' button on my main menu or access' 'x'), the 'export to excel' form loads beautifully and the 'export to excel' button works great except my other button on that form, the 'exit' button, does not work at all.

The exit button is set to 'quit -> prompt'. This is completely nitpicking, but how do I get this 'quit' button to work. Clicking on that form's 'x' button closes that window and continues the exit and I could just write I note saying 'click the x to exit', but I'd rather figure out what's broken here and fix that exit button. If I set that button to 'quit -> exit' I get an action failed error # 2950.

View Replies


ADVERTISEMENT

Modules & VBA :: Main Form Load Event Firing On Application Quit?

Aug 6, 2013

I'm developing in Access 2007 and created a runtime version.

When the user clicks the X to close the runtime application, the main form's Load event fires. Any clues as to why this might be? Some of the code is based on other forms that do close, so of course errors start flying. Note, this is only in the runtime version; the accdb file works just fine.

My current workaround is to put the offending code into the forms On Current event, which I'm able to do in this context.

Is it wrong to think that a forms On_Load event shouldn't be firing when the application is closing?

View 1 Replies View Related

Event When Exit Application From SwitchBoard

Feb 25, 2007

I have a switchboard with an exit button to exit the application. I want to add an event so it executes when user exit the application from the switchboard.

how to do that.

or how can I access the procdure for the application exit attach the event to

View 2 Replies View Related

On Exit Event - Tab/click Header Vs. Detail

Jan 6, 2006

I have a continuous form, with data entry fields in both the form header and the detail section.

I've attached an "On Exit" event to the ProdQty field in the detail section. The prime function of the event code is to run an update query on the table (which is the data source for the form).

The code executes properly (update query runs successfully and form refreshes) when I Tab out of that field. It also executes properly when I use the mouse to click on another field in the detail section.

However, when I use the mouse to click on a field in the form header or form footer sections, the On Exit code does not execute properly.

Here's the On Exit Sub:

Private Sub ProdQty_Exit(Cancel As Integer)
On Error GoTo ProdQty_Error

If (Int(Me!ProdQty) <> Me!ProdQty) Or ((Me!ProdQty / Me!LDU) < 1) Or (Int(Me!ProdQty / Me!LDU) <> (Me!ProdQty / Me!LDU)) Then
Me.ProdQty.BackColor = 255
Me.ProdQty.ForeColor = 16777215
Beep
MsgBox "The quantity you entered is invalid for this product." & vbCrLf & vbCrLf & "Please check the LDU (least divisible unit) and enter a new quantity.", vbExclamation, "Quantity Error"
DoCmd.GoToRecord acActiveDataObject, "Order Form", acPrevious
DoCmd.GoToRecord acActiveDataObject, "Order Form", acNext
DoCmd.GoToControl "ProdQty"
Exit Sub
Else
Me.ProdQty.BackColor = 255
Me.ProdQty.BackColor = 16777215
Me.ProdQty.ForeColor = 0
DoCmd.SetWarnings False
DoCmd.OpenQuery "Update Product Qty in Current Order", acViewNormal, acEdit
Me.Requery
Me.Refresh
Me.Repaint

DoCmd.GoToControl "ProductCombo"
End If

ProdQty_Error:
Exit Sub

End Sub

Here's the Update Query:

UPDATE [Current Order] INNER JOIN Products ON [Current Order].[Product #] = Products.[Product #] SET [Current Order].Quantity = Forms![Order Form]!ProdQty, [Current Order].Price = IIf([Forms]![Order Form]![PriceCodeCombo]="CS",[Products]![Contract Net]*([Forms]![Order Form]![ProdQty]/[Forms]![Order Form]![ProdLDU1]),IIf([Forms]![Order Form]![PriceCodeCombo]="EDW",[Products]![Ed Wholesale]*([Forms]![Order Form]![ProdQty]/[Forms]![Order Form]![ProdLDU1]),IIf([Forms]![Order Form]![PriceCodeCombo]="R2",[Products]![R2 Net]*([Forms]![Order Form]![ProdQty]/[Forms]![Order Form]![ProdLDU1]),IIf([Forms]![Order Form]![PriceCodeCombo]="R3",[Products]![R3 Net]*([Forms]![Order Form]![ProdQty]/[Forms]![Order Form]![ProdLDU1]),IIf([Forms]![Order Form]![PriceCodeCombo]="R4",[Products]![R4 Net]*([Forms]![Order Form]![ProdQty]/[Forms]![Order Form]![ProdLDU1]),IIf([Forms]![Order Form]![PriceCodeCombo]="R5",[Products]![R5 Net]*([Forms]![Order Form]![ProdQty]/[Forms]![Order Form]![ProdLDU1]),IIf([Forms]![Order Form]![PriceCodeCombo]="R6",[Products]![R6 Net]*([Forms]![Order Form]![ProdQty]/[Forms]![Order Form]![ProdLDU1]),IIf([Forms]![Order Form]![PriceCodeCombo]="W",[Products]![Wholesale Net]))))))))
WHERE ((([Current Order].[Product #])=[Forms]![Order Form]![Product1]));

I tried copying that code to "After Update", "On Change", and "On Lost Focus" events but the results were the same.

Any suggestions would be greatly appreciated. Thanks!

View 5 Replies View Related

Round Buttons Or Oval Buttons Instead Of The Normal Square Buttons

May 30, 2005

Hello everybody,

I’m new here and I have a question for you..

Is it possible to place round buttons or oval buttons on your forms instead of the normal square ones?

Greets,

Tom

View 2 Replies View Related

Access Won't Quit

Mar 6, 2008

Hello again folks.

Having spent a week building my database and everything is working as expected - I set the 'startup' properties and now Access won't save or quit from the main form. In order to close I have to select 'form design' and then the 'X' will work. This goes for all the methods of closure including the menu and system buttons. I cannot access the cnt/Alt/Del with this system but that's immeterial. I'm using XP and Access 2000.

I have tried removing all the conditionally formatted controls.

Help please!!

Chalkie.

View 7 Replies View Related

Queries That Won’t Quit

Aug 20, 2005

Sorry to bug you guys (or Gals) for something as simple as this.

I have several subforms and list boxes that references other subforms using queries and when I close the form using

DoCmd.Close


Some of the queries ask for parameter values. Is there a little snippet that will fix this?

Thanks Everyone,

View 8 Replies View Related

Employee Quit?

Dec 15, 2005

I have a form which has a drop down box which links to a table with Employee names. One employee quit and I want to delete her name from the table. But... if I do that, I will delete her entirely from all previous records. Is there a way to keep all previous records, but take her out of the drop down choices?

View 2 Replies View Related

My Code To Quit The Application Has A Bug!

May 19, 2005

Hi I have succsefully used the code suggested on theis excellent forum to boot user from the db to repair it. It is FE/BE set up and the ONTIMER on the login form is used to chuck people off over the network.

My ug is: I like to give people the waring before I chuck them off, but sometimes when they are using another application with the db running in the background they dont get the message, therefore dont click ok so my Code wont carry on and Quit application when I want it to.

The code is trapped in

MsgBox "Please finish what your doin, as the db will shut down", vbinformation

Is there any way I can make my code bypass this if they user hasnt clicked ok?

Many thanks in advance

View 1 Replies View Related

Update Excel Before Quit....

Nov 3, 2004

Hi
I'm trying to create a commandbutton that will update a Microsoft query in excel.
My problem is that excel is quitting before the workbook is updated. Maybe I need a "wait" command or something...
This is what i have:

Private Sub cmdASP_Click()
Dim XL
Dim XLARK
Set XL = CreateObject("excel.application")
Set XLARK = GetObject("c: est.xls")
XL.Visible = True
XLARK.Parent.Windows(1).Visible = True
XLARK.Activate
XLARK.RefreshAll
XLARK.Application.Cells(1, 1).Value = Now()
XL.ActiveWorkbook.Close Savechanges:=True
XL.Quit
Set XL = Nothing
Set XLARK = Nothing
End Sub

Can anyone help me out?

eroness

View 5 Replies View Related

Form Onclose Open Another Form

Sep 7, 2005

I would like to create a splash screen for my database, when the splash screen form closes I would like it to open another form (the main menu which is a switchboard form)

Anyone help?

Cheers

View 1 Replies View Related

General :: Parameter Box Pops Up On Application Quit

Jul 17, 2013

When my database application is closed a parameter box pops up asking for parameter from text16 but only if the Navigation Pane is hidden.

Some information:

The application starts with a login screen that has a hidden text box (text16) that allows me to limit what users can access throughout the database by setting it as the query criteria.

If a form is open that is gathering its data from one of these querys and you try to close the application the parameter box opens which is simply annoying for my users who do not know about access.

The interesting thing about this is that if I unhide the Navigation Pane and close the application with one of these forms open it closes fine with no parameter box pop up.

The goal is to have the Navigation Pane hidden and the parameter box not pop up.

Added information if the navigation pane is hidden I can use a command button with a macro that closes all open forms then quits application and this does not cause the parameter box to pop up.

So another fix for my problem would be to disable the "X" close button at the top right of the application.

View 7 Replies View Related

Modules & VBA :: Command To Execute When Form Is Closed Or Quit

Feb 5, 2015

There is a form where whenever the form is closed, the below code needs to execute:

If IsNull(Me.CostPerPiece1.Value) = True And IsNull(Me.CostPerPiece2.Value) = True And IsNull(Me.CostPerPiece3.Value) = True And IsNull(Me.CostPerPiece4.Value) = True And IsNull(Me.CostPerPiece5.Value) = True Then
Me.AllowAdditions = False
DoCmd.SetWarnings (0)
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings (-1)
Else
Call AppendQuoteCharges
End If

The If Then just looks at if certain fields are all null and if so, it deletes the current record. If at least one field is not null, the AppendQuoteCharges routine is called.

The form has 4 or 5 navigation buttons that close this form and send you to a different one. I've added the above code to each of those buttons before it runs the DoCmd.Close Form. I also have a Exit button that runs a DoCmd.Quit. I developed this months back but I'm pretty sure I added the above code under each button's click event rather than a Form On Close event because Form On Close does not execute after a DoCmd.Quit command

In rare cases, the form is being closed without the routine being ran. I think if a user clicks the Close button in the top right of Access (the X), it might be running a DoCmd.Quit which is doesn't run this code.

How can I be sure that whenever the form is closed or exited, the code is ran? Is there a way to tie this code to the user clicking the X in the top right?

View 2 Replies View Related

General :: Application Always Quit In Access Runtime On Every Run-time Error

Mar 24, 2014

I have setup a small application with front/back end in local network. On client machines i have installed access runtime. Although it works fine but it suddenly quit when there is any run time error while working on client machine. Although on server machine ( where full version is running it didn't close the application ).

What i need is an option to not quit the application completely. As i am not expert in coding of try/catch statements I need a simple solution for time being .

View 5 Replies View Related

Modules & VBA :: Application Quit Doesn't Work On Network Users

May 26, 2014

My database is used by a few users on a shared drive in "read-only" mode so they can't change any data.I set a scheduled task to copy an updated version of the database (which I edit) every morning.

The problem is that when the users forget to close the database file I can't overwrite it.For this purpose I wrote a small code that quits the application at 00:00 using Application.Quit.The code WORKS when I test it on my computer, but every morning when I try to open the file I see that it is opened by another user since I also open it as "read-only" - meaning the code didn't work...getting the code to work properly OR get a better solution to be able to overwrite the file even though it's opened by other users.

View 10 Replies View Related

Change Colour Of Navigation Buttons And Command Buttons?

Mar 17, 2006

Is this possible? I can't seem to find this q anywhere here so I thought I'd post.

I changed the colour of my form to white, but the Navigation Buttons at the bottom and the command buttons that I 've added stay at the default grey.

Is there anyway to change this? I right-clicked and tried changing it to white through the properties but there's nothing there that does this.

:confused:

View 2 Replies View Related

Change Colour Of Navigation Buttons And Command Buttons?

Mar 17, 2006

Is this possible? I can't seem to find this q anywhere here so I thought I'd post.

I changed the colour of my form to white, but the Navigation Buttons at the bottom and the command buttons that I 've added stay at the default grey.

Is there anyway to change this? I right-clicked and tried changing it to white through the properties but there's nothing there that does this.

:confused:

View 4 Replies View Related

Exit Help

Jun 6, 2005

Does anyone know the code to exit from THE whole ACCESS program.

That is when I click the close button on the switchoboard, I want the system to close the whole of access program.

View 3 Replies View Related

Using X To Exit

Nov 14, 2006

If my user uses the MS Access 'X' button (upper right hand of screen) to Exit the application does anyone know what methods are triggered that may let me perform some task before the application actually ends?
Thanks

View 1 Replies View Related

My Switchboard Won't Exit!

Jun 27, 2005

I've created a new database using the standard Switchboard function. However, when I use the Exit Application command the database closes but MS Access stays open. It's a minor problem but infuriating, especially as I've never encountered this problem before and everything I try won't fix it. Any ideas?

View 5 Replies View Related

Hangs & Exit

Aug 21, 2005

I'm having an application which is developed in access. It's running quite well, some times when I made changes to forms or reports it hangs for a while and exits without saving, it happens sometimes not always... what could be the problem? how can I rectify this..

View 3 Replies View Related

Backup On Exit

Oct 13, 2005

Hiya,

I have a database which on exit runs calls the following module and backs up the database to anther folder

Public Function BackupCopy()

'This function will allow you to copy a db that is open,

'You must set a reference to the 'Microsoft Scripting Runtime' for the CopyFile piece to work!

Dim fso As FileSystemObject

Dim sSourcePath As String
Dim sSourceFile As String
Dim sBackupPath As String
Dim sBackupFile As String

sSourcePath = "C:Database"
sSourceFile = "MyDB.mdb"
sBackupPath = "C:DatabaseBackups"
sBackupFile = "BackupDB_" & Format(Date, "mmddyyyy") & "_" & Format(Time, "hhmmss") & ".mdb"

Set fso = New FileSystemObject
fso.CopyFile sSourcePath & sSourceFile, sBackupPath & sBackupFile, True
Set fso = Nothing

Beep
MsgBox "Backup was successful and saved @ " & Chr(13) & Chr(13) & sBackupPath & Chr(13) & Chr(13) & "The backup file name is " & Chr(13) & Chr(13) & sBackupFile, vbInformation, "Backup Completed"

End Function

but after backing up correctly it brings me the following error

"Run-time errror '424':

Object required

any ideas what might be going wrong

Cheers

View 1 Replies View Related

Help: Exit Access

Feb 16, 2007

Hi all,

How would i close access via vba after a function runs?
I know how to close a form, but id like to close the entire thing.

Thanks in advance

View 2 Replies View Related

Exit Code

Jun 15, 2005

I have a form that automatically is shown when a user enters the database. I want to disable all exits of this form so that the user cannot exit the form before he/she exits the whole database. How do I do this?

View 2 Replies View Related

Exit Form

Dec 1, 2006

I have a form with 4 tab pages. on the 2 tab page I have a subform that adds records to a table via 2 combo boxes.

I have been able to stop user from leaving a combo control blank or skipping to the next combo control, but if user clicks the Exit command button on the main form, from the 2nd combo control, it prompts that value has to be selected but the gives error:

"You cannot add or change record because a related record is required"

How can I stop this so form will close and undo the 1st combo selection and not give error?

View 1 Replies View Related

Compress On Exit

Jul 30, 2014

What are the pro's and con's and setting the database to compress on Exit?

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved