Hi, can someone tell me please why my strforname and strsurname aren't getting popualted in this loop.
When it gets to the right record, it's finding the surname and forename but then not putting them in the string (inside the If statement) so I can show them in a text box.
The staffcode is an integer being passed to the function.
Public Function StaffDetails(staffCode)
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strForename As String
Dim strSurname As String
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("StaffDetails", dbOpenTable)
Do While rst!ID <> staffCode
If rst!ID = staffCode Then
strForename = rst!Forename
strSurname = rst!Surname
End If
rst.MoveNext
Loop
[Forms]![frmFundingRequest]![txtSurname] = strSurname
[Forms]![frmFundingRequest]![txtForename] = strForename
End Function
Much appreciated.
When it gets to the right record, it's finding the surname and forename but then not putting them in the string (inside the If statement) so I can show them in a text box.
The staffcode is an integer being passed to the function.
Public Function StaffDetails(staffCode)
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strForename As String
Dim strSurname As String
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("StaffDetails", dbOpenTable)
Do While rst!ID <> staffCode
If rst!ID = staffCode Then
strForename = rst!Forename
strSurname = rst!Surname
End If
rst.MoveNext
Loop
[Forms]![frmFundingRequest]![txtSurname] = strSurname
[Forms]![frmFundingRequest]![txtForename] = strForename
End Function
Much appreciated.