I would be grateful if someone could give me a direction in solving
this problem. Here is the simplified setup for the code that I am
trying to run in an Access form. STRFLD is an array that I assigned
earlier. I am trying to access for example rs!Fields!AREG or
rs!fields!ASER depending on what STRFLD was supplied earlier in the
code. To save space I shortened my SQL and code quite a bit, but I hope
this will give you a picture of what I am trying to do.
Dim db As Database
Dim rs As Recordset
STRSQL = "SELECT mms.[LINKNUM], TableA.[SER] AS ASER, TableB.[SER] AS
BSER FROM TableA LEFT JOIN TableB ON TableB.LINKNUM = TableA.LINKNUM
ORDER BY TableA.SER;"
Set db = CurrentDb()
Set rs = db.OpenRecordset(STRSQL, dbOpenDynaset)
icol = 1
I have tried the following
strdat = rs!Fields("A" & STRFLD(icol)) ' I get a run-time error
3265 Item not found
strdat = rs.fields(fldnm) ' where fldnm = "A" & STRFLD(icol) again
I get error 3265
strdat = Controls("rs!Fields(" & fldnm & ")") ' Get a error 2465 can't
find field 'rs!Fields(AREG)'
I have even tried CallByName and countless other combinations of the
above examples. I know the field exists in the database. I know
STRFLD(icol) was set right because on debug I can see it has the right
value. I have searched help as well as many newsgroup postings and
have not found my solution. Have I overlooked something? Is it
possible to have a dynamic field in a recordset?
Thank you very much!
-Matt