[SOLVED]Please help. SQL Problem giving a ComboID
Good evening dear programers.
Running the code below :
I get the following error : Runtime Error '3464' : Data type mismatch in criteria expression .
I am aware that this comes from the expression after WHERE statement , but my problem is that I tried getting the checkvar value by Dlookup , me.CmbName.Value , me.CmbName.Column(0) - where 0 is the column for Emp_ID , and I always get the same mistake . Where is the key to solve this ?
I have already dimmed checkvar as Integer . I am sure that Emp_ID is defined in its table as AutoNumber............
Hope I formuled my question correct.
Best regards .
P.S -> J.F.Y.I CreateDynamicReport is a public function that creates and opens a report with a "Title" = sname and fields from the selection variable .
Good evening dear programers.
Running the code below :
Code:
Private Sub Command299_Click()
Dim selection As String
Dim sname As String
If IsNull(Me.cmbWorkerNameReport.Column(0)) Then
MsgBox ("Choose Worker !")
Exit Sub
End If
Dim checkvar As Integer
checkvar = DLookup("Emp_ID", "tbl_Employees_General_Info", "Emp_ID = " & Me.cmbWorkerNameReport.Column(0))
sname = DLookup("Emp_First_Name", "tbl_Employees_General_Info", "Emp_ID = " & Me.cmbWorkerNameReport.Column(0)) & " " & DLookup("Emp_Last_Name", "tbl_Employees_General_Info", "Emp_ID = " & Me.cmbWorkerNameReport.Column(0))
selection = "SELECT Emp_First_Name, Emp_Last_Name , Emp_Notes " _
& "From tbl_Employees_General_Info " _
& "WHERE (((Emp_ID) = '" & checkvar & " ')) "
CreateDynamicReport selection, sname
End Sub
I am aware that this comes from the expression after WHERE statement , but my problem is that I tried getting the checkvar value by Dlookup , me.CmbName.Value , me.CmbName.Column(0) - where 0 is the column for Emp_ID , and I always get the same mistake . Where is the key to solve this ?
Hope I formuled my question correct.
Best regards .
P.S -> J.F.Y.I CreateDynamicReport is a public function that creates and opens a report with a "Title" = sname and fields from the selection variable .
Last edited: