RunSql Insert Into

G

Guest

On a form that the user is working with there is a control named 'ToCompany'.
When new information is entered into this field I am trying to append it to
a table named 'CustomerData' into 'CustomerName' (after update event).

DoCmd.RunSQL "INSERT INTO CustomerData" & "CustomerData.CustomerName_
Forms!frmFLCDeliver.Controls!tocompany"

I am getting an error. Does anyone have any suggestions.
 
D

Douglas J. Steele

If what you're trying to do is add the contents of a control named tocompany
on form frmFLCDeliver into a field named CustomerName as a new row in table
CustomerData, the syntax is

"INSERT INTO CustomerData (CustomerName) " & _
"VALUES (""" & Forms!frmFLCDeliver.Controls!tocompany & """)"

That assumes CustomerName is a text field.
 
G

Guest

Douglas:
That did the trick, thank you. If I wanted to add other fields from the
form to the same table (one record) would I use repeating DoCmd's or combine
them using variables?
 
G

Guest

Thanks again Douglas:

With your example I was able to peice together the code that will do exactly
what I want.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top