A
ArielZusya
I've got three tables as follows:
tblMain
.ID_Main
.RefNum
tblMainEvent
.ID_MainEvent
.Person
.Event
.Status
.EventLog
tblRefNum
.RefNum
.BatchNum
I'd like to insert into tblMainEvent for each record in tblMain that has a
RefNum in tblRefNum with a particular BatchNum. I can write the queries
seperately as follows:
qryAllInBatch1:
SELECT tblMain.ID_Main
FROM tblTrial LEFT JOIN tblMain ON tblRefNum.RefNum = tblMain.RefNum
WHERE (((tblRefNum.BatchNum)=1));
and then:
INSERT INTO tblMainEvent ( Person, Event, Status, EventLog )
SELECT qryAllInBatch1.ID_Main, 1, 1, Now()
FROM qryAllInBatch1 LEFT JOIN tblMainEvent ON
qryAllInBatch1.ID_Main=tblMainEvent.Person
WHERE tblMainEvent.Juror IS NULL;
But I'd like to ultimately embed the SQL in VBA so I'd like to combine these
two into one longer SQL statement. Is it possible to run the second SQL
statement with the first embedded rather than using qryAllInBatch1? Thanks!
tblMain
.ID_Main
.RefNum
tblMainEvent
.ID_MainEvent
.Person
.Event
.Status
.EventLog
tblRefNum
.RefNum
.BatchNum
I'd like to insert into tblMainEvent for each record in tblMain that has a
RefNum in tblRefNum with a particular BatchNum. I can write the queries
seperately as follows:
qryAllInBatch1:
SELECT tblMain.ID_Main
FROM tblTrial LEFT JOIN tblMain ON tblRefNum.RefNum = tblMain.RefNum
WHERE (((tblRefNum.BatchNum)=1));
and then:
INSERT INTO tblMainEvent ( Person, Event, Status, EventLog )
SELECT qryAllInBatch1.ID_Main, 1, 1, Now()
FROM qryAllInBatch1 LEFT JOIN tblMainEvent ON
qryAllInBatch1.ID_Main=tblMainEvent.Person
WHERE tblMainEvent.Juror IS NULL;
But I'd like to ultimately embed the SQL in VBA so I'd like to combine these
two into one longer SQL statement. Is it possible to run the second SQL
statement with the first embedded rather than using qryAllInBatch1? Thanks!