J
Judy Ward
I feel like I have entered the twilight zone. I want a recordset that
contains the SCR_ID, SCR_Element and SCR_State for the specific SCR_ID's
selected by the user. When I execute the code I can see that what I have for
strSQL returns exactly what I want. But for some reason the RecordSet
contains every SCR_ID in the table (4,000 of them!) not just the specific
SCR_ID's I can see in strSQL. SCR_ID is a text field.
Here is part of the code (storing only the SCR_ID for now):
strSQL = "SELECT SCR_ID, SCR_State, SCR_Element FROM tblSCR WHERE SCR_ID = "
& strSCRs
Debug.Print strSQL
' Returns:
' SELECT SCR_ID, SCR_State, SCR_Element FROM tblSCR WHERE SCR_ID = '6071' OR
'6072'
Set db = CurrentDb()
Set rstSCRs = db.OpenRecordset(strSQL, dbOpenSnapshot)
Do While Not rstSCRs.EOF
varConcat = varConcat & rstSCRs("SCR_ID") & "; "
rstSCRs.MoveNext
Loop
Debug.Print varConcat
' Returns every SCR_ID in the table
I cannot figure out what I am doing wrong. Any help would be appreciated.
Thank you,
Judy
contains the SCR_ID, SCR_Element and SCR_State for the specific SCR_ID's
selected by the user. When I execute the code I can see that what I have for
strSQL returns exactly what I want. But for some reason the RecordSet
contains every SCR_ID in the table (4,000 of them!) not just the specific
SCR_ID's I can see in strSQL. SCR_ID is a text field.
Here is part of the code (storing only the SCR_ID for now):
strSQL = "SELECT SCR_ID, SCR_State, SCR_Element FROM tblSCR WHERE SCR_ID = "
& strSCRs
Debug.Print strSQL
' Returns:
' SELECT SCR_ID, SCR_State, SCR_Element FROM tblSCR WHERE SCR_ID = '6071' OR
'6072'
Set db = CurrentDb()
Set rstSCRs = db.OpenRecordset(strSQL, dbOpenSnapshot)
Do While Not rstSCRs.EOF
varConcat = varConcat & rstSCRs("SCR_ID") & "; "
rstSCRs.MoveNext
Loop
Debug.Print varConcat
' Returns every SCR_ID in the table
I cannot figure out what I am doing wrong. Any help would be appreciated.
Thank you,
Judy