I'm have an Object not found.
In tools I have checks on "Visual Basic For Applications", "Microsoft Access 15.0 Object Library", "OLE Automation", "Microsoft ActiveX Data Objects 6.1 Library", "Microsoft ActiveX Data Objects Recordset 6.0 Library" and "Microsoft Office 15.0 Access database engine Object Library"
I do have the query name correct I copied and paste the name.
Any Idea where I should look.
In tools I have checks on "Visual Basic For Applications", "Microsoft Access 15.0 Object Library", "OLE Automation", "Microsoft ActiveX Data Objects 6.1 Library", "Microsoft ActiveX Data Objects Recordset 6.0 Library" and "Microsoft Office 15.0 Access database engine Object Library"
I do have the query name correct I copied and paste the name.
Any Idea where I should look.
VBA Code:
Function Junk()
Dim Rep, Email_Bcc, Email_Body As String
Dim Mail_Object, Mail_Single As Variant
' Get Email Info
Dim o As DAO.Recordset
Dim MyVendor, MyEmail, MyAp1, MyVendor1, MyGL1, MyAp2, MyVendor2, MyGL2, MyAp3, MyVendor3, MyGL3, qrySQLItems
Set o = CurrentDb.OpenRecordset("Vendor")
MyVendor = o![Vendor Name]
MyEmail = o!
MyAp1 = o![Ap Numbers 1]
MyVendor1 = o![Vendor Numbers 1]
MyGL1 = o![GL 1]
MyAp2 = o![Ap Numbers 2]
MyVendor2 = o![Vendor Numbers 2]
MyGL2 = o![GL 2]
MyAp3 = o![Ap Numbers 3]
MyVendor3 = o![Vendor Numbers 3]
MyGL3 = o![GL 3]
qrySQLItems = "SELECT TblTeradata.AP_Vendor, TblTeradata.Vendor, TblTeradata.GL, TblTeradata.AP_Vendor_Name, TblTeradata.Code, " _
& "TblTeradata.[CA Crosscode], TblTeradata.[DU Crosscode], TblTeradata.[HG Crosscode], TblTeradata.[NE Crosscode], TblTeradata.[PW Crosscode], " _
& "TblTeradata.[OL Crosscode], TblTeradata.Description, TblTeradata.Pack, TblTeradata.Size, TblTeradata.Buyer, TblTeradata.Dest, " _
& "TblTeradata.Warehouse, TblTeradata.Dlt, TblTeradata.UPC_VNDR, TblTeradata.UPC_CASE, TblTeradata.UPC_ITM, TblTeradata.Vendor_Name, " _
& "TblTeradata.Chain_Name FROM TblTeradata WHERE "
If Not IsEmpty(AP1) Then
qrySQLItems = qrySQLItems & "(((TblTeradata.AP_Vendor) In (" & MyAp1 & ")))"
If Not IsEmpty(GL1) Then
If Not IsEmpty(AP1) Then
qrySQLItems = qrySQLItems & " OR "
End If
qrySQLItems = qrySQLItems & "(((TblTeradata.Vendor) In (" & MyGL1 & "))"
End If
End If
If Not IsEmpty(MyVendor1) Then
If Not IsEmpty(AP1) Then
qrySQLItems = qrySQLItems & " OR "
End If
qrySQLItems = qrySQLItems & "(((TblTeradata.Vendor) In (" & MyVendor1 & "))"
If Not IsEmpty(GL1) Then
If Not IsEmpty(Vendor1) Then
qrySQLItems = qrySQLItems & " OR "
End If
qrySQLItems = qrySQLItems & "(((TblTeradata.Vendor) In (" & MyGL1 & "))"
End If
End If
qrySQLItems = qrySQLItems & " ORDER BY TblTeradata.AP_Vendor;"
DBEngine(0)(0).QueryDefs("QryItem List").SQL = qrySQLItems
DoCmd.OpenQuery "QryItem List"
End Function
Last edited by a moderator: