Dlookup bafflement

Withnail

New member
Local time
Today, 19:07
Joined
Apr 5, 2001
Messages
7
Hello all.

I am getting a data type mismatch error when I run the following code to pick up from a table "Tbl_Name" once a a piece of work has been allocated to a developer.

Private Sub Cmd_E_mail_Allocate_Click()
Dim SetName As Integer
Dim GetEmail As Variant

If IsNull([Allocated_To]) Then
MsgBox "You have not allocated a developer to the MTR.", vbExclamation + vbOKOnly, _
"No allocation"
Allocated_To.SetFocus
Else
SetName = Allocated_To.Value
GetEmail = DLookup("[Email]", "Tbl_Name", "[Name_ID] = '" & SetName & "'")

End If

End Sub
 
If Tbl_Name is numeric then you DLookup statement should look like this:

GetEmail = DLookup("", "Tbl_Name", "[Name_ID] = " & SetName)
 

Users who are viewing this thread

Back
Top Bottom