View Full Version : Dlookup bafflement


Withnail
07-24-2001, 03:49 AM
Hello all.

I am getting a data type mismatch error when I run the following code to pick up [Email] 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

Jack Cowley
07-24-2001, 06:06 AM
If Tbl_Name is numeric then you DLookup statement should look like this:

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