Access 2010 Inserting temporary variables into fields in a table

thao-nhi
thao-nhi used Ask the Experts™
on
How do I insert  tempvar values into existing fields in a table? I have values from a form assigned to temporary variables through a macro. I would like to insert them to an existing table by way of a macro. Please elaborate the syntax when doing this in an insert query.

thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
To Append to a table:
Insert Into NameOfTable (NameOfField1, NameOfField2) Values (TempVars!NameOfTempVar1, TempVars!NameOfTempVar2)

Open in new window

To Update a table:
Update NameOfTable Set NameOfField1 = TempVars!NameOfTempVar1, NameOfField2 = TempVars!NameOfTempVar2

Open in new window

Ron
Distinguished Expert 2017

Commented:
Is this a one time data fix up?  How will you determine the correct value?  How will you determine which row to update?  Are you thinking you need to scroll through the recordset of the form and update one record at a time (not a good idea)?  

This type of bulk update should be done with a query if the value is constant such as populating a field with a default value.  If the value is calculated, you shouldn't be doing this at all.  Calculations should happen in the query when you retrieve the data.

Update YourTable Set SomeField = 0 Where SomeField Is Null;

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial