Hi All,
The error I am getting is 3265:
"Item not found in this collection."
How should I be passing in the vReturnFieldNam e so it will be recognized as
a value in the collection?
Thanks for your assistance.
Information:
I pass four variables to the FindNameString function and want it to return
the value of field:
strProjectPrime in table 'Project Primes"
The table "Project Primes" has two fields
lngProjectPrime ID and strProjectPrime
Private Sub TestRun()
MsgBox FindNameString( "Project Primes", "lngProjectPrim eID",
"strProjectPrim e", 21)
End Sub
Public Function FindNameString( vTblName As String, vFindFieldName As String,
_
vReturnFieldNam e As String, vFindFieldValue As Long) As String
On Error GoTo FindNameString_ Error
Dim rs As Recordset
Set rs = CurrentDb.OpenR ecordset(vTblNa me, dbOpenSnapshot)
If rs.RecordCount > 0 Then
rs.FindFirst "[" & vFindFieldName & "]=" & vFindFieldValue
If rs.NoMatch = False Then
FindNameString = rs![vReturnFieldNam e] 'rs![ProjectPrime]
Else
FindNameString = 0
End If
End If
rs.Close
Set rs = Nothing
On Error GoTo 0
Exit Function
FindNameString_ Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
FindNameString of Module Conversion"
End Function
Comment