Insert data from table and form

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

Guest

I need to insert data into Table1 from Table2 and the Main form. Here's the
scenerio: I need to insert into Table1 fields: ForecastID, PartNumber,
Quantity.
ForecastID is obtained from the Main form's txtForecastID textbox.
PartNumber and Quantity are both from Table2.

This is what I have so far:
sql = "INSERT INTO Table1 (PartNumber, Quantity) "
sql = sql & " SELECT [PartNumber], [Quantity] FROM Table2 "

But I'm not sure how I can include txtForecastID in the sql statement.
Thanks in advance.
 
Try something like ...

sql = "INSERT INTO Table1 (PartNumber, Quantity, ForecastID) "
sql = sql & " SELECT [PartNumber], [Quantity], " & Me!txtForecastID & " as
Fid FROM Table2 "
 

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