DLookup statement from SQL to VBA

kosanhing

New member
Local time
Today, 21:45
Joined
Dec 15, 2016
Messages
4
Please help to solve this statement, it appear the "Too few parameters expected 1".
The problem is on the "IIf(IsNull([tblMaintWO]![Technian1]),'', DLookup('Initial', tblEmployees, 'EmpID=' & [tblMaintWO]![Technian1])) AS TechnianA " and I can't put the double quotes in the statement otherwise it show red sentence and got error.

Code:
strSQL = "SELECT tblMaintWO.MWONo, tblMaintWO.TaskOpenDate, tblMaintWO.MTRStation, tblMaintWO.Task, tblMaintWO.RequestedPriority, tblMaintWO.WorkOrderStatus, tblMaintWO.Technian1, "
strSQL = strSQL & "IIf([CMFollowUp] = True, 'CM', IIf([PreventiveMaint] = True, 'PM', IIf([EIVO] = True, 'EI/VO', 'Other'))) AS TaskType, "
strSQL = strSQL & "IIf(IsNull([tblMaintWO]![Technian1]),'', DLookup('Initial', tblEmployees, 'EmpID=' & [tblMaintWO]![Technian1])) AS TechnianA "
strSQL = strSQL & "FROM tblMaintWO, tblEmployees;"
 
DONT use Dlookup in a query. The query IS the dlookup.
join your data table to the tEmployees table on the EmpID. This does the same thing faster.
 
Dear Ranman256,

Thank you for your reply.

After your suggestion, I found the way to make it. Thank you very much!
 

Users who are viewing this thread

Back
Top Bottom