Using Eval () with DAO.Recordset - is it possible?

I am using DAO.recordset (called rs2) based on SQL query (in MS Access). Calling up individual attributes in a recordset is simple:

strName = rs2!Name
strDescr = rs2!Descr

I am trying to come up with a more general way of referencing attributes through a variable without success using the Eval () function.

Is something like this possible?

strAttr = "Name"
strResult = Eval("rs2!" & strAttr)

Any suggestions to fulfill?

+3
source share
1 answer

Eval()evaluated by the Access expression service. And this service does not know about VBA variables, including object variables, such as your recordset rs2.

But I don’t think you need something like Eval()that to get what you want. Use strAttrto refer to this name in the record collection .Fields.

strAttr = "Name"
strResult = rs2.Fields(strAttr).Value
+4

All Articles