-
SQL Where and recordset
I am trying to set the where clause of a sql statment for creating a recordset based on the value in another recordset field and when i use the sql in an open recordset operation that i know is good i get an error. Simplified it looks like this
SELECT field1 and field2 FROM table one
WHERE field1 = rsRecordset.Field1
Here is the entire statement
strSQL = "SELECT tblDefectDetails.DefectDetail_ID, tblDefectDetails.DefectDetail_tblDefectReportID, tblDefectDetails.DefectDetail_Dimension, tblDefectDetails.DefectDetail_CondOth, tblDefectDetails.DefectDetail_Tolerance, tblDefectDetails.DefectDetail_Actual, tblDefectDetails.DefectDetail_InspectionReviewResult, tblDefectDetails.DefectDetail_InspectionReview_tblPersonnelID, tblDefectDetails.DefectDetail_Note" & _
" From tblDefectDetails" & _
" WHERE (((tblDefectDetails.DefectDetail_tblDefectReportID)= '" & rstDefectReport!DefectReport_ID & "'));"
rstDefectReport is open, contains matching records, and is at first record
rstDefectReport!DefectReport_ID contains a 3
tblDefectDetails.DefectDetail_tblDefectReportID contains 2 records with a value of 3 so the resultant recordset should have those two records
Where did i go wrong? the procedure that opens the recordset is ok because i use it multiple times in the program and this is the only instance where it gives me an error.
do i need to use shaped recordsets?
How can i accomplish this?
-
got it on my own.. if i drop the opening and closing ' it works