Select From

  • Thread starter Thread starter DS
  • Start date Start date
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
 
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
 
Back
Top