Saving a record entered via a form

greaseman

Closer to seniority!
Local time
Today, 17:45
Joined
Jan 6, 2003
Messages
360
I've got a bound form that works quite well. My question is.... I'm putting a command button on the form that will "save" the record when it is clicked. For a reason not obviously apparent to me, I usually end up with two records being saved to the table that's bound to the form. What might be a smart way to eliminate anything being saved until the user actually clicks on the "Save" command button?

(It seems that when the user presses the enter key after putting in data, that that is where the "default" save is happening. I know how to use code on a form that is unbound to get around this, but am having a heck of a headache on this one. Maybe it's because I've been awake since 4:00 AM.

You guys (and girls!!) on this forum are great! I've learned more from this forum than from a lot of Access books and Microsoft. Thank you so much!!
 
Save problems

Instead of using a 'save' button you can put the code below in the Before Update Event of the form.

When the record has been edited and the user closes the form or goes to a new or different record, a messagebox will pop up giving the user the option to save the changes, or not.


Dim strMsg As String
strMsg = "Data has been changed"
strMsg = strMsg & "Save this Record?"

If MsgBox(strMsg, vbYesNo, "") = vbYes Then
'do nothing
Else
DoCmd.RunCommand acCmdUndo
End If


May be this will work for you.
 
Don't know if this will work for you but, check that the properties of the form are set to enable data entry. Instructions on how to do this can be found in Access's help utility (Search under Form, topic: Specify whether a form opens in data entry mode).

Then, on my form I have a SAVE button. On the button's properties, under Events, under On Click, I have a macro.

The macro is very basic: the first Action is Save. Object Type and Object name are blank. The second Action is GoToRecord. Object Type is blank, Object Name is blank, Record is Next, and Offset is blank.

Hope it works, or if there's a better way to do this I hope someone lets us know!
 
What took y'all so long to reply ??? :) Thanks for the suggestions! What I was / am trying to do is to use a "Save" button to work whether a record is edited or a new record is added. Perhaps I confused "poor little Access." I'm just trying to stay away from writing a ton of code (one part for editing / saving, one part for new data / saving.)

Again, thanks for your help.....it's nice to know there are good people out there.
 
Thank you!

trucktime said:
Instead of using a 'save' button you can put the code below in the Before Update Event of the form.

When the record has been edited and the user closes the form or goes to a new or different record, a messagebox will pop up giving the user the option to save the changes, or not.

(snip...)

May be this will work for you.

It's so cool when I find exactly what I'm looking for, within a minute of checking out today's posts. :)

Karin.
 

Users who are viewing this thread

Back
Top Bottom