Saving on Application Closing

Benjamin1986

Board Regular
Joined
May 18, 2007
Messages
60
This is a frustrating item dealing with users who just can't be bothered to press the buttons to close the form down correctly.

I have a log in access with a very nice bound form to enter all the data. Unfortunately, the user has to log off the computer several times each shift (bad design, but not under my control).

Now, the problem. The users are best described as "set in their ways", and one of the ways they like closing things down is by simply logging off. Everything closes down neatly, right? Everything except that it runs the form "on-close" event and throws an error message when it gets to the only partially important "runCommand acCmdSaveRecord" line. It throws the error, doesn't save, and I get yelled at.

Ideas?
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
You could start by telling them that it's a great way to corrupt the database. If Access isn't shut down properly, it gets left in an unstable state. You might be alright for a while, then you will start getting all sorts of weird errors.

You could also chuck some data validation in, so that users can't try to save the record unless all the data has been entered into required fields. For example, say you have a RequiredDate field that must be filled in. Put code like this in the form's Before Update event --
Code:
If IsNull([RequiredDate]) Then
    MsgBox "You must enter a date in the RequiredDate field"
    Cancel = True
    Me.RequiredDate.SetFocus
End If

You can do that for as many fields as you need.

Denis
 
Upvote 0
The problem isn't the data validation. The data is fine (the validation is code-only, not hardwired into the database tables to avoid that problem). Sorry if I'm not making that clear.

It's just that the changes won't save no matter what data is in the fields if they log off, or hit the X in the top right corner, or even Alt-F4. I'm sorry, but the log-off one was the one that I discovered immediately before posting, so it was in my mind. The only way that it saves the data is if you click the "Close form" button (I disabled the form's control box, so that isn't an option). Closing the application while the form is open runs the form_Close event, but throws an error on the saverecord.

I'm tempted to put the saverecord command as a LostFocus event for every single textbox, but that might clog up the server with unnecessary traffic.
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,392
Members
449,081
Latest member
JAMES KECULAH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top