INSERT INTO from Sub2 Form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to copy a value from a control to a table using INSERT INTO. The
problem I'm having is referencing the control properly.

I'm running this in the Before Update of a control on a subform of a subform
of the mainform:

DoCmd.RunSQL "INSERT INTO Table (Field) VALUES
(Me.Subform1.Form.Subform2.Form.ControlName)"

What am I doing wrong?
 
If you are running this in subform 2, you shouldn't need all those
references. Me.ControlName should be fine. Your syntax for the SQL is
a little off though too. Its

"INSERT INTO Table (Field) " & _
"VALUES (" & Me.ControlName & ")"

If the value you are inserting is a text value, then you'll need a
single quote after the ( and one before the ).

Hope that helps!
 

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

Back
Top