Jenkins
asked on
Add a record to a table and confirm it was added - MS Access
I have an Access database with a form that has 3 textboxes (textbox1, textbox2, textbox3) and a command button.
I have an Access table (MyTable) with 3 fields (Field1, Field2, Field3).
I need the code that will write (i.e. add a record) the textbox data to the table (textbox1 goes to Field1, textbox2 goes to Field2, etc) when the command button is clicked and I also need to confirm that the record was actually added.
Thank you.
I have an Access table (MyTable) with 3 fields (Field1, Field2, Field3).
I need the code that will write (i.e. add a record) the textbox data to the table (textbox1 goes to Field1, textbox2 goes to Field2, etc) when the command button is clicked and I also need to confirm that the record was actually added.
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
How is this question different from the earlier one where you marked Crystal's answer as correct?
Also -- it will be very helpful in future if you give your fields, controls and forms (and other objects) meaningful names. The Leszynski Naming Convention (LNC) is generally used. I have created free add-ins to semi-automatically apply the appropriate LNC prefixes to database objects and controls -- here are some links (there are different versions for different Access versions):
LNC Rename add-in (Access 2000-2003)
http://www.helenfeddema.com/Files/code10.zip
http://en.wikipedia.org/wiki/Leszynski_naming_convention
LNC Rename add-in (Access 2007-2010)
Controls only:
http://www.helenfeddema.com/Files/code63.zip
Objects and Controls:
http://www.helenfeddema.com/Files/code63.zip
LNC Rename add-in (Access 2000-2003)
http://www.helenfeddema.com/Files/code10.zip
http://en.wikipedia.org/wiki/Leszynski_naming_convention
LNC Rename add-in (Access 2007-2010)
Controls only:
http://www.helenfeddema.com/Files/code63.zip
Objects and Controls:
http://www.helenfeddema.com/Files/code63.zip
-set the Record Source of the form to MyTable
- set the textboxes Control Source to Field1, Field2, Field3 respectively
- you can then use the command button to move the form to New record, the form will be ready to take a new input
place this code in the click event of the command button
private sub button_Click()
docmd.GoToRecord,,acNewRec
end sub