var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Insert records into 2 tables
I would like to insert records into 2 tables after I select a record from the drop down.
In the main form there is a dropdown where you can select a Group type.
I need the code of how to insert (create) new records for the existing order as follows.
Insert a record for the selected Group type, into tblOrderDetails
Then, Insert part records tblOrderSubDetails, based on tblGroupType.DefaultPartNumbers for the selected Group type.
Can you please share the insert statement that I need?
I know its not written clear, but I believe if you open the sample DB, you will understand what I need.
just run an append query. Use the keys of the record you are on.
then they will show up after the refresh.
Thanks for the response.
It needs to first create a record in tblOrderDetails and then into tblOrderSubDetails (and populate in tblOrderSubDetails the new generated record number from tblOrderDetails)
Where can I see the "qsAdd2Rescs" query?
I have never made such an insert. Can anyone please help write this insert sql? As mentioned above, I believe if you open the sample DB, you will understand what I need. Thanks
You could use the following,
If me.dropdownbox.value = "GroupType1" then
DoCmd.RunSQL "INSERT INTO Yourtablename (Field1,Field2,Field3) VALUES ('Value1','Value2','Value3')"
Elseif me.dropdownbox.value = "GroupType2" then
DoCmd.RunSQL "INSERT INTO Yourtablename (Field1,Field2,Field3) VALUES ('Value1','Value2',Value3')"
You will need to replace the text in bold with your data, also depending on what your Value is will depend on how it is defined in the Value of the Docmd.runsql insert into section.
If it is Text then as follows 'Text'
If it is True or False then " & True & "
If it is a tempvar or field then '" & TempVars!Var & "'
Hope this makes sense,