How do I keep Access from saving automatically?

gbell1sc

New member
Local time
Today, 09:17
Joined
Apr 15, 2011
Messages
6
I have set up an access 2003 database for work. I am a somewhat newbie to Microsft Access - the last time I used it was in 2004 for High School! Anyway, I have made a database with several tables and one main form for entering data. I want to make it so that when you open the form, and when you have changed data, before closing, Access will ask you if you want to save the data or not. I would also like it to do the same before navigating to the next record. On the form, I have put in the save button, but realised it is actually pointless as Access will save the data on the form before going to a new record/next record and before it closes the form. So - as a newbie (baring in mind I don't klnow VBA code!) can someone provide me with a step by step guide to accomplish what I need, i.e. click on here, type this, click on this etc etc?
 
gbell1sc -

I moved your question to its own thread as it was really only lightly related to the other one.

What you can do is use the form's BEFORE UPDATE event to validate/ask if the user wants to save the record. In that event you can check to see if all fields are filled out like you want or you can simply just ask if they want to save or you can discard things if they haven't clicked your save button.

So this might help:
http://www.pcreview.co.uk/forums/re-save-data-only-button-clicked-t3989356.html
 
Bob,
Will the BeforeUpdate event work if you close the form using the X on the corner ?
 
Form_BeforeUpdate occurs anytime you leave a record after having entered/edited data in that record. It makes no difference whether you move to another record, close the form using a custom 'close' button or close a form with the 'big X.'

Linq ;0)>
 
the thnig is, this is standard behaviour in databases, and is what every user expects. In addition there are loads of ways to move/save records. eg - what about the search faciliites (eg binoculars or ctrl-F) Are you going to disable all of these?

so the question is - why do you want it to work in another way.

one solution is, maybe, not to force the save via a button - but set the cycle property to "current record" - and force the user to press a navigation key, to get to a different record.


and if you still want to avoid automatic saves, the easiest way is to have an unbound form - but this carries a different set of challenges.
 
Thanks Link :)

I normaly disable the form's close button, and use my oun save/close one. I think it look more proffesional this way. I keep it for msg boxes and such.

I think most users intutively expact the close button to behave as Close+Cancel and not as Close+Save (default behavior)
 
Personally I don't like NOT having a normal "close" button, Nearly every form in every normal windows app, has a close button.

Not having one means the user has to hunt for how to close the form.

I disable the close button very very sparingly
 
Thanks Link :)I think most users intutively expact the close button to behave as Close+Cancel and not as Close+Save
Not if they're experienced Access users! And 'close' buttons, in any professionally developed app, where data/text is entered, do just what Bob has told you
to do; they pop up a message box to ask if you whether or not you want to save your data/text that has been entered.
 
@Dave - I put 2 big buttons - OK, Cancel

@Linq - Most users are not experienced Access users. They don't even care the application was built in Access.

How do you cancel the form close, to validate data ?

a quote from the help Bob posted:
The *only* way to catch the save is to use the BeforeUpdate event of the
form. Access fires that event regardless of what triggers the save.

In general, this is bad technique...
 
each to his own, i guess.

there's more than 1 way to skin a cat.
 
each to his own, i guess.

there's more than 1 way to skin a cat.
Sure :)

I never saw any application that the close button also used to validate the data before saving. it will ask the user either to save the existing changes made, or not.
 
I never saw any application that the close button also used to validate the data before saving
That just shows your inexperience in these things!

As Dave said, "each to his own." But don't ask the help of experienced developers if you don't want it!
 
That just shows your inexperience in these things!

As Dave said, "each to his own." But don't ask the help of experienced developers if you don't want it!
Maybe I'm not as expert in VBA and Access as many other here, though I started my Access experience since Access 2.0 (Many years ago :D) I do believe I'm expert in computers and in many other applications as I use them for the last 25 years.

As I said, I saw many applications using the close button (The X one) to ask the user either he want to save changes or not, but never saw one that also validate the data after the user said he want to save.
Maybe I'm wrong but I think a user will expact this close method to be Close+Finish, not to be Continue to work.

Also I got no answer to my question "How do you cancel the form close, to validate data ?"
Cancel = True won't work for the OnClose event.

So it's not a thing of experienced developer or not, it's just a metter of intuitive human thinking. Unfortunately I saw many mistakes in this metter that are made by very talent and experenced developers.
 
smig

i think you are right in one way.

if you use the before update event to validate an entry and obtain confirmation that the record is OK - then if it IS valid, you will always be asked to confirm the save, even when you are not closing the form. (and I don't think there is a way round this, as you point out - it's something I have tried to do in the past)

So, I don't think there is a way of saying - this record is saving BECAUSE THE FORM IS CLOSING, therefore handle it in a different way.

Therefore one solution is to do what you are doing - which is to remove the close button altogether. And another is to accept default access behaviour - which is that closing the form tries to save the record, without prompting the user.

(Hope this isn't too confusing either ...)
 
So, I don't think there is a way of saying - this record is saving BECAUSE THE FORM IS CLOSING, therefore handle it in a different way.

Actually there is. What I do, in cases like that, is create a boolean flag in the General Declarations section of the form's module. Something like blnClose and then I set the flag to true in the save button's click event. In the Before Update event, I check to see if the boolean is true. If it is, I know that they clicked the save button. If it isn't I can simply cancel the update, undo and close (or do any other number of paths I might choose based on the scenario).
 
@Bob - how do you cancel/undo the close (clicking the X) ?
 
I presume Bob uses the UnLoad event of the form to cancel the closing of the form.

Code:
Private Sub Form_Unload(Cancel As Integer)
If MsgBox("Close?", vbYesNo) = vbNo Then
    Cancel = True
End If
End Sub

JR
 

Users who are viewing this thread

Back
Top Bottom