By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,968 Members | 1,247 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,968 IT Pros & Developers. It's quick & easy.

Command button to save record

P: 18
I have a bound form to a table.
I have a command button to save when clicked that uses the following code.

Private Sub Commandsaverecord_Click()
On Error GoTo Err_Commandsaverecord_Click

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit Sub

MsgBox Err.Description
Resume Exit_Commandsaverecord_Click

End Sub

How do I get the form to only save when the save button is clicked?
Aug 10 '09 #1
Share this Question
Share on Google+
5 Replies

Expert 100+
P: 1,287
You could use unbound fields, then in the button code copy the values from the unboud fields to hidden bound fields, then save the record. There may be a way to cancel the table update in a bound control's update event, but I haven't tried it or seen anything about it.
Aug 10 '09 #2

Expert 100+
P: 904
Using unbound controls like Chip says will work or you could use a cancelevent command in the BeforeUpdate event of the form.

Aug 10 '09 #3

P: 18

What would that look like?
Aug 10 '09 #4

Expert 100+
P: 904
Feeling a bit lazy today so I just made a quick demo instead of explaining it. Take a look and let me know if this helps.

Attached Files
File Type: zip (28.5 KB, 2040 views)
Aug 10 '09 #5

Expert 2.5K+
P: 3,532
mshmyob's code is a neat way of doing this, but I have a problem with custom "save" buttons in Access. Experienced data entry users of Access know that moving to another record or closing a form is supposed to save the current record, by default. Adding a "save' button like this is adding another, unnecessary step, and data entry people, especially those in a production data entry situation, hate things that adds steps.

If your intent is to be sure the user wants to save the modified/new record, you simply need to add a messagebox to the Form_BeforeUpdte event asking them to save or dump it.

Linq ;0)>
Aug 11 '09 #6

Post your reply

Sign in to post your reply or Sign up for a free account.