I am using a DAO recordset to update a table due to problems with enocuntered here .
This works fine when I know the name of the field I'm updating, for example:
rs2.AddNew
rs2![ContactID] = rs.Fields(0).Value
rs2![Fee Protection Insurance] = "" & strValue & ""
rs2.Update
works great.
However, the field I'm trying to update will not always have the same name, so I also tried to use the variable here, expecting it to be evaluated and equivalent to the above code:
rs2.AddNew
rs2![ContactID] = rs.Fields(0).Value
rs2!["strFieldName"] = "" & strValue & ""
rs2.Update
but it tells me that the item is not in the collection, even when strFieldName is set to Fee Protection Insurance.
I tried these various ways, including:
rs2![" & strFieldName & "] = "" & strValue & ""
rs2![strFieldName] = "" & strValue & ""
rs2!["" & strFieldName & ""] = "" & strValue & ""
rs2![cStr(strFieldName)] = "" & strValue & ""
none of them work.
Am I mistaken about this, or am I trying to do something impossible?