N
NevilleT
I have a module that is generic and I want to pass values to it. Basically
it compares 2 recordsets (rstOld and rstNew) and if there is a difference,
will identify the old and new values. At this stage I am just printing them.
While Not rstOld.EOF
strCriteria = "[UserAccessNo] = " & rstOld!UserAccessNo
rstNew.MoveFirst
rstNew.FindFirst strCriteria
If rstNew!Read <> rstOld!Read Then
Debug.Print rstOld!Read & " " & rstNew!Read
End If
rstOld.MoveNext
Wend
What I would like to do is replace "rstOld!UserAccessNo" with a string so
that for other tables, I can pass the primary key field name as a parameter.
For example, if instead of "UserAccessNo", the field was "PersonNo", I would
call the sub with a parameter
subCheckValues(strFieldName as string).
If the value I pass to strFieldName is "PersonNo" I thought the following
would work.
dim strFullName as string
strFullName = "rstNew!" & strFieldName
strCriteria = "[UserAccessNo] = " & strFullName
Unfortunately no. Having spent about a day on it, it is time to turn to the
experts. How can I use a string to refer to a field value in a recordset?
it compares 2 recordsets (rstOld and rstNew) and if there is a difference,
will identify the old and new values. At this stage I am just printing them.
While Not rstOld.EOF
strCriteria = "[UserAccessNo] = " & rstOld!UserAccessNo
rstNew.MoveFirst
rstNew.FindFirst strCriteria
If rstNew!Read <> rstOld!Read Then
Debug.Print rstOld!Read & " " & rstNew!Read
End If
rstOld.MoveNext
Wend
What I would like to do is replace "rstOld!UserAccessNo" with a string so
that for other tables, I can pass the primary key field name as a parameter.
For example, if instead of "UserAccessNo", the field was "PersonNo", I would
call the sub with a parameter
subCheckValues(strFieldName as string).
If the value I pass to strFieldName is "PersonNo" I thought the following
would work.
dim strFullName as string
strFullName = "rstNew!" & strFieldName
strCriteria = "[UserAccessNo] = " & strFullName
Unfortunately no. Having spent about a day on it, it is time to turn to the
experts. How can I use a string to refer to a field value in a recordset?