update dataentry through form

mitraexport03

New member
Local time
Today, 10:30
Joined
Jun 24, 2014
Messages
3
Hello sir,
good day
I am beginner to access database , I have created data entry form having add button to add record.
I want to update the record in table as soon as i click add button
so pl. any one can show me the vba code

thanks in advance
ajit vyas
 
Make the form bound and save yourself a lot of grief.
Else you will need to use an Update query on that Add button.
 
Hello sir,
good day
I am beginner to access database , I have created data entry form having add button to add record.
I want to update the record in table as soon as i click add button
so pl. any one can show me the vba code

thanks in advance
ajit vyas
Because Bound Forms automatically save the current record when you move focus to a different record, there is no need for an additional manual Save for that record.
Your "Add" button does just that, it saves the current record and moves focus to a new record, ready for you to create and save that new one.
 
People generally use an "Add" button to go to a new, empty record rather than to save the record they just updated/added. This process automagically saves the current record if it is dirty. If for some reason, you want the updated record to be saved but not close the form or advance to a new record, add a button labeled simply "Save" and use DoCmd.RunCommand acCmdSaveRecord to save the current record and stay on it. This will cause your validation code in the Form's BeforeUpdate event to run and give you any error messages. If no errors, the event proceeds to save the record. If your code finds errors, you display an appropriate error message, set Cancel = True and exit the event to leave the record dirty and allow the user to correct it.

The two buttons allow the same form to work logically for both Add and Save operations. But, as George mentioned, Access has your back here. You don't need custom buttons when the form is programmed to save any record that is dirty. It isn't saving a record that new people have trouble with, it is stopping Access from saving that becomes problematic. For that, you need to understand how to control the save by using validation code in the Form's BeforeUpdate event. That gives you total control. Save or don't save. YOU decide.
 

Users who are viewing this thread

Back
Top Bottom