Access 2007 insert into table where source is another table and form

Martinus

New member
Local time
Today, 13:36
Joined
Feb 4, 2015
Messages
3
Hi to every one,

I have a question:

If you want to use a "DoCmd.RunSQL "INSERT INTO" command to insert data in a table and the data to insert comes from a table and a form, could this be done in one pass?

So...writing a record wit 4 values from table1 together with a additional value from a textbox in table2 as 5 values.

Hope you guys understand what i mean

greets

martinus
 
Hello JHB,

That's wonderfull :-)

Can you explain it a bit by showing a piece of code and explaining the piece of code.

I know how to do the form bit and i know how to do the table bit, but combining the 2!

Thanks
 
Below is the code, remember to change the field and table names to yours and if the field in which the value from the textbox goes is number, remove the ':
DoCmd.RunSQL ("INSERT INTO ToTable ( FieldName1, FieldName2, FieldName3, FieldName4, FieldName5 ) " _
& "SELECT FromTable.FieldName1, FromTable.FieldName2, FromTable.FieldName3, FromTable.FieldName4,'" & Me.TheTextBox & "' " _
& "FROM FromTable")
 
Hi JHB,

Thanks for the example :-)

I figured it out and understand it now.

Again thankks for your help

Martinus
 

Users who are viewing this thread

Back
Top Bottom