Solved Run-time error 2465

Kayleigh

Member
Local time
Today, 17:14
Joined
Sep 24, 2020
Messages
709
Hi, Working on simple piece of code which compiles, but when run I get an error. Checked the field names and all seem correct...
Any ideas?
Code:
Private Sub Form_Current()
If Not (DLookup("fldPositionName", "qryStaffRolesConcat", [fldStaffPositionID] = 24)) Then
Me.txtRoles = ConcatRelated("fldPositionName", "qryStaffRolesConcat", "fldStaffID = " & [fldStaffID])
End If
End Sub

run time error.png
 
The last argument of the DLookup is a string. You have not used any quote marks in yours.
 
Tried that. Now getting a different error...
 

Attachments

  • error 13.png
    error 13.png
    5.6 KB · Views: 101
No should definitely be 24.
Code:
Private Sub Form_Current()
If Not (DLookup("fldPositionName", "qryStaffRolesConcat", "[fldStaffPositionID] = 24")) Then
Me.txtRoles = ConcatRelated("fldPositionName", "qryStaffRolesConcat", "fldStaffID = " & [fldStaffID])
End If
End Sub
 
No should definitely be 24.
Code:
Private Sub Form_Current()
If Not (DLookup("fldPositionName", "qryStaffRolesConcat", "[fldStaffPositionID] = 24")) Then
Me.txtRoles = ConcatRelated("fldPositionName", "qryStaffRolesConcat", "fldStaffID = " & [fldStaffID])
End If
End Sub
My mistake, I was reading the '13' as a value you had used. o_O

However Dlookup is going to return a string/numeric of fldPositionName I would have thought, not a boolean True or False?
 
If you don't need a value from a table, but just need to know it exists I would use a DCount:


DLookup can return NULL and those can be a pain to work around. DCount is guaranteed to return a number.
 

Users who are viewing this thread

Back
Top Bottom