PDA

View Full Version : Pass values from form to a table in Access



marcis_boi06
08-19-2008, 02:15 PM
Hi, new here so please be gentle lol.

I have a form that a user enters personal details into, i want these to be transferred via VB to a table in Access but i dont know? ive tried searching but cant grasp what im being told :(

If someone answers this might they also know how to retrieve the values back? and how to retrieve from specific cells in the table?

Thank you very much for help

OBP
08-20-2008, 03:38 AM
marcis, why do you want to use VBA to reproduce what Access does anyway?

There are 2 basic methods to do this using VBA, one involves using an "SQL" statement to create a "Recordset" and the other uses a Recordset based directly on the table or Query that you have already created (the query is basically the same as an SQL Statment).
When you open the Recordset any values in the table automatically become available for "reading back", however to put the values in a table you have to use the "Addnew" function of a recordset.

There are already lots of examples of how to do it on this Forum.

CreganTur
08-20-2008, 08:22 AM
Welcome, Marcis! It's always good to see new members.

Tony's exactly right- but changing the field values on a form will only automatically update the values in the connected Table if the recordset is updateable.

If the recordset that is feeding your Form is not updateable, then I would suggest using a SQL Update query to update the table's field values to the new values on the form. This is also what you would use to update field values in your table when you are using Unbound textboxes on your Form.