Full Version: How do I Properly Save Records?
UtterAccess Forums > Microsoft® Access > Access Forms
Centity
Hey UA,
I have some forms here with a save button that saves the record. Of course with access saving the records every time they are modified it defeats the purpose of having the button (which the users want).
So I try doing a BeforeUpdate "would you like to save" validation which cancels the update on "NO." Of course now if you press the save button upon selecting NO, the update cancels and the save button executes the SAVE command which results in an "action canceled" error.
Before I just disable that error-box I was wondering if there is a common, ideal way of handling this
Hopefully something like, access does not try to update the records at all unless the save button is pressed? What are some ways that you guys handle this issue?
ALaRiva
Unbound Forms
It's the only way to go, IMHO.
Bound Forms are too clunky for my tastes.
theDBguy
One way to handle it is by using an unbound form, but you'll have to save each control's value to the table in code with your Save button.

Hope that helps...

Edit Added:

Oops... looks like Anthony beat me to the punch, so I feel obligated to give you another suggestion.

Since Access saves the data for you automatically anyway that there's no need for a save button, but the user wants it, why not just "pretend" that the user is actually using the Save button to save the data. For example, you can have the Save button show a message box confirming the (bogus) save. Or, if you want to keep your confirmation message, you can empty each control when the user clicks the No option. Another thought might be to assign a boolean value to a global variable to indicate if the user wants to save the record, and then in the BeforeUpdate event of the form, check the variable and Cancel the update if the value was False.

Hope that helps...

Edited by: theDBguy on Thu Sep 4 13:51:07 EDT 2008.
Centity
Bound forms are clunky but in this case they use it to filter so I'd like to keep it bound.
learing the controls when a user clicks no is also not that great because what if they just changed their mind and need to edit one character.
The global variable way also seems like a sloppy workaround but that's what I wound up going with.
Thanks for your help.
ALaRiva
I know you chose a solution, but I'd just like to point out that even though they use it to filter that's not a deal breaker for going unbound. Anything/Everything can be done unbound, just need to know which methods/controls/tools to use.
Centity
>
Ounderstand that, but the amount of time it would take me to redo all of their forms from bound to unbound would not be worth it for such a small issue. Had I created this DB myself I would have went ahead with unbound forms.
ALaRiva
Gotcha! I was referring to just this specific form, my assumption was that you were just getting the project started.
theDBguy
Glad to hear you got a solution. Good luck with your project.
Centity
thanks again =)
theDBguy
You're welcome. thumbup.gif
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.