I keep getting this syntax error, missing operator in query expression [ID] = Soldering System. Can someone please help me?
Dim oOutlook As Outlook.Application
Dim oEmailAddress As MailItem
Dim MyEmpName As String
Dim temp As String
Dim MyEquip As String
Dim MyModel As String
Dim MyAsset As String
Dim MySerial As String
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset(MySQL)
If rs.RecordCount > 0 Then
rs.MoveFirst
Do Until rs.EOF
If IsNull(rs!EmailAddress) Then
rs.MoveNext
Else
If oOutlook Is Nothing Then
Set oOutlook = New Outlook.Application
End If
Set oEmailAddressItem = oOutlook.CreateItem(olMailItem)
With oEmailAddressItem
MyEmpName = DLookup("EmpName", "Employees", "[EmpID]= " & rs!EmpName)
MyEquip = DLookup("[EquipmentType]", "Equipment", "[ID]=" & rs!EquipmentType) This is the line where I keep getting that error message as well as the three Dlookup statements below.
MyModel = DLookup("ModelNo", "Equipment", "[ID]= " & rs!ModelNo)
MyAsset = DLookup("AssetNo", "Equipment", "[ID]= " & rs!AssetNo)
MySerial = DLookup("SerialNo", "Equipment", "[ID]= " & rs!SerialNo)
.To = "another@.com;another@.com;another@.com"
.Subject = "Calibration that's due between 1 to 11 months" & MyEmpName
.Body = "Calibration ID: " & rs!RecordID & vbCr & _
"Location: " & rs!CalLocation & vbCr & _
"Requirement: " & rs!Requirement & vbCr & _
"Employee: " & MyEmpName & vbCr & _
"Name: " & MyEquip & vbCr & _
"Serial No.: " & MySerial & vbCr & _
"Model No.: " & MyModel & vbCr & _
"Asset No.: " & MyAsset & vbCr & _
"Due Date : " & rs!CalUpcomingDate & vbCr & vbCr & _
"This email is auto generated. Please Do Not Replay!"
.Display
'.Send
' rs.Edit
' rs!DateEmailSent = Date
' rs.Update
End With
Set oEmailAddressItem = Nothing
Set oOutlook = Nothing
rs.MoveNext
End If
Loop
Else
'do nothing
End If
rs.Close
Exit_Function:
Exit Function
End Function