Select From

D

DS

I need to select from two table in this SQL statement. How can this be
accomplished?

DoCmd.SetWarnings False
VDSQL = "INSERT INTO tblVoidDetails " & _
"SELECT * FROM tblCheckDetailsTMP " & _
"WHERE tblCheckDetailsTMP.CDCheckID = Forms!frmFXVoidSelect!TxtCheckID " & _
"AND tblCheckDetailsTMP.CDGroupID = Forms!frmFXVoidItem!TxtGroupID " & _
"AND tblCheckDetailsTMP.CDSubGroupID = Forms!frmFXVoidItem!TxtSubGroupID;"
DoCmd.RunSQL (VDSQL)
DoCmd.SetWarnings True

The two Tables are tblCheckDetailsTMP and tblCheckDetails.
Would an Or statement work like this?

DoCmd.SetWarnings False
VDSQL = "INSERT INTO tblVoidDetails " & _
"SELECT * FROM tblCheckDetailsTMP Or tblCheckDetails" & _
"WHERE tblCheckDetailsTMP.CDCheckID = Forms!frmFXVoidSelect!TxtCheckID " & _
"AND tblCheckDetailsTMP.CDGroupID = Forms!frmFXVoidItem!TxtGroupID " & _
"AND tblCheckDetailsTMP.CDSubGroupID = Forms!frmFXVoidItem!TxtSubGroupID;"
DoCmd.RunSQL (VDSQL)
DoCmd.SetWarnings True

Thanks
DS
 
D

Dale Fye

Let me make sure I understand what it is you are trying to do.

You have 2 tables (tblCheckDetails and tblCheckDetailsTMP). Is that correct?

I think what you want to do is insert all of the fields from either of these
2 table into tblVoidDetails, if the CDCheckID, CDGroupID, and CDSubGroupID
values in either table match the values in the textboxes in your form. Is
that correct?

Dale
 

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

Similar Threads

OR or AND 2
SQL Not Updating 2
UNION Error 9
SQL SYNTAX ERROR 8
SELECT INSERT 1
Not Updating 2
SQL ORDER BY 1
Loop SQL 5

Top