M
MikeC
I'm trying to do the following:
1) Obtain the *name* of a field from one ADO recordset
(rst1).
2) Obtain the *value* of this field from a second ADO
recordset (rst2).
3) Concatenate the field *value* to a string that I am
building inside a loop.
Below is a code fragment:
'===========================================
With rst1
If strLtr <> vbNullString Then
strLtr = strLtr & CStr(rst2!Eval("[" & !FieldName
& "]")) & strLineFeed
Else
strLtr = CStr(rst2!Eval("[" & !FieldName & "]")) &
strLineFeed
End If
End With
'===========================================
When I execute the code, I get the below error:
Error #3265 - "Item cannot be found in the collection
corresponding to the requested name or ordinal."
The error occurs in the *Eval* function. I'm guessing
that VBA is looking for the field in the rst1 recordset.
It doesn't seem to know that I want it to look for the
field in rst2. I've tried approximately 15 different
variations of the above, and I just don't seem to know how
to make VBA understand that I'm referencing a field
contained in rst2.
Does anyone understand how to fix this code?
Any help you can offer would be greatly appreciated.
Thanks.
1) Obtain the *name* of a field from one ADO recordset
(rst1).
2) Obtain the *value* of this field from a second ADO
recordset (rst2).
3) Concatenate the field *value* to a string that I am
building inside a loop.
Below is a code fragment:
'===========================================
With rst1
If strLtr <> vbNullString Then
strLtr = strLtr & CStr(rst2!Eval("[" & !FieldName
& "]")) & strLineFeed
Else
strLtr = CStr(rst2!Eval("[" & !FieldName & "]")) &
strLineFeed
End If
End With
'===========================================
When I execute the code, I get the below error:
Error #3265 - "Item cannot be found in the collection
corresponding to the requested name or ordinal."
The error occurs in the *Eval* function. I'm guessing
that VBA is looking for the field in the rst1 recordset.
It doesn't seem to know that I want it to look for the
field in rst2. I've tried approximately 15 different
variations of the above, and I just don't seem to know how
to make VBA understand that I'm referencing a field
contained in rst2.
Does anyone understand how to fix this code?
Any help you can offer would be greatly appreciated.
Thanks.