vba - Insert values from two different tables into another different table with concatenate -


i have button uses 2 separate queries pull data 2 tables , insert table:

dim lngid long dim lngidcallout long dim strsql1 string  lngid = calloutattendance_multiselect.value lngidcallout = forms![callouts].[calloutid].value  strsql1 = "insert members_callouts(memberid) select memberid members memberid=" & lngid     strsql2 = "insert members_callouts(calloutid) select calloutid callouts calloutid=" & lngidcallout  currentdb.execute strsql1 currentdb.execute strsql2 calloutattendance_multiselect.requery 

and whilst want do, inserts the 2 values 2 separate new records, whereas i'd insert 1 new record. i've had go, either syntax errors, or in case below, got 3067 runtime error "query input must contain @ least 1 table or query"

strsql1 = "insert members_callouts(memberid, calloutid) select           (select memberid members memberid=" & lngid & "),           (select calloutid callouts calloutid=" & lngidcallout & ")" 

anyone know might going wrong?

thanks :-)

in case you're inserting key values need is

strsql1 = _         "insert members_callouts (memberid, calloutid) " & _             "values (" & lngid & ", " & lngidcallout & ")" 

in other words, don't need bother like...

"(select memberid members memberid=" & lngid & ")" 

...since value returns lngid (assuming value exists in [members] table).


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -