michael1174
asked on
Late binding DAO
I am using DAO and querydef... what would be the correct late binding?
I keep getting this erro:
ActiveX component can't create object
My code is below.. i think it is crashing on:
Set db = CurrentDb()
what would be the late binding for that?
I keep getting this erro:
ActiveX component can't create object
My code is below.. i think it is crashing on:
Set db = CurrentDb()
what would be the late binding for that?
Dim db As Database
Dim rs As Recordset
Dim qdf As QueryDef
Set db = CurrentDb()
Set qdf = db.QueryDefs("qryRptWeeklyEmail")
Try explicitly defining these as DAO, and make sure your references are set properly (tools -> references, make sure DAO x.x is checked):
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim db As DAO.Database
Dim rs As DAO.Recordset
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Be sure you have a reference set to DAO 3.xx in Tools>>References ....
mx
mx
ASKER
I'm giving my client the mde and i dont want to have to specify the reference.....
Then angeliii's second suggestion should work for you.
Why not just:
Set qdf = CurrentDb.QueryDefs("qryRp tWeeklyEma il")
Set qdf = CurrentDb.QueryDefs("qryRp
If this is an Access app (which it sounds like since you said your giving the client a MDE) then I would not use late binding. There is a substantial performance hit in doing so. Besides, there is not a ton that can go wrong with DAO as a reference. It's considered part and parcel of Access (actually JET).
JimD
ASKER
databaseMX, I'll try that as well...it works fine on my computer, but doesnt on my client's computer...
"but doesnt on my client's computer..."
Why not ? It should work on any computer.
mx
Why not ? It should work on any computer.
mx
ASKER
my client is still getting the error... maybe its the late binding on my outlook procedure....does it look right?
Private Sub EmailActivityReport(strClientName, strEmail)
Dim objOutlook As Object
Dim objOutlookMsg As Object
Dim objOutlookRecip As Object
Dim objOutlookAttach As Object
Dim arrEmail
Dim l_counter
Const olTo As Long = 1
Const olMailItem As Long = 0
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
arrEmail = Split(strEmail, ",")
For l_counter = 0 To UBound(arrEmail)
Set objOutlookRecip = .Recipients.Add(arrEmail(l_counter))
objOutlookRecip.Type = olTo
Set objOutlookRecip = Nothing
Next
' Set the Subject, Body, and Importance of the message.
.Subject = "Invoice Activity Summary For " & strClientName
.Importance = 2 'high importance
.HTMLBody = strReport
' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next
.Send
End With
Set objOutlook = Nothing
Set objOutlookMsg = Nothing
Set objOutlookRecip = Nothing
Set objOutlookAttach = Nothing
End Sub
ASKER
does anything look wrong here:
Public Sub CreateEmailActivityReport()
Dim rs As Object
Dim qdf As Object
Dim strEmail As String
Dim intClientID As Integer
Dim intLastClientID As Integer
Dim curTotalOriginalBalance As Currency
Dim curTotalRevisedBalance As Currency
Dim curTotalTotalCredits As Currency
Set qdf = CurrentDb.QueryDefs("qryRptWeeklyEmail")
qdf!pClientID = Forms!frmReports!cboClientID
qdf!pInvoiceFromDate = Forms!frmReports!txtInvoiceFromDate
qdf!pInvoiceToDate = Forms!frmReports!txtInvoiceToDate
qdf!pCarrierID = Forms!frmReports!cboCarrierID
qdf!pAuditorID = Forms!frmReports!cboAuditorID
Set rs = qdf.OpenRecordset
If rs.EOF Then
MsgBox "Please assign email addresses to clients before running this report", vbInformation, strCompany
Exit Sub
End If
.....
What line of code does that error occur on ?
mx
mx
ASKER
in my original post, it was occuring on the :
Set db = CurrentDb()
but once i changed
Dim db As Database
to
Dim db As Object
it was fine on my computer...
that was only way i could duplicate the error... nothing else has given me the error, so i'm not sure where it exactly is occuring on my clients computer...
Set db = CurrentDb()
but once i changed
Dim db As Database
to
Dim db As Object
it was fine on my computer...
that was only way i could duplicate the error... nothing else has given me the error, so i'm not sure where it exactly is occuring on my clients computer...
Do you have a reference set to DAO for sure ? When you create a new MDB and go into code, the default reference (sadly) is ADO.
mx
mx
ASKER
I don't have a reference to DAO.. should I? if I am giving them an mde.. also, sorry, this is an access 2007 accde.
I've defined it as:
I've defined it as:
Dim rs As Object
Dim qdf As Object
Set qdf = CurrentDb.QueryDefs("qryRptWeeklyEmail")
Set rs = qdf.OpenRecordset
I believe OpenRecordset in Set rs = qdf.OpenRecordset is going to require a Reference to DAO. Can you try that?
mx
mx
ASKER
ok, i try and add it and i get this error:
name conflicts with existing module, project, or library
i have checked:
visual basic for applications
microsoft access 12.0 object library
ole automation
microsoft office 12.0 access database engine object library
microsoft activex data objects 2.8 library
name conflicts with existing module, project, or library
i have checked:
visual basic for applications
microsoft access 12.0 object library
ole automation
microsoft office 12.0 access database engine object library
microsoft activex data objects 2.8 library
ASKER
i just removed:
microsoft office 12.0 access database engine object library
and it allowed me to add it...
gonna see if it works at my clients cpu...
microsoft office 12.0 access database engine object library
and it allowed me to add it...
gonna see if it works at my clients cpu...
ok ... you're in A2007, right?
I guess microsoft office 12.0 access database engine object library is the DAO reference ... I'm not at my A2007 machine right now.
Typically that reference would look like:
Microsoft DAO 3.6 Object Library ....
mx
I guess microsoft office 12.0 access database engine object library is the DAO reference ... I'm not at my A2007 machine right now.
Typically that reference would look like:
Microsoft DAO 3.6 Object Library ....
mx
soooo, what was the problem ?
mx
mx
ASKER
It actually had something to do with either the outlook automation call or the dao call, and my client didn't have the windows automatic update on, so my version of access 2007 was newer than his version.. the MSO numbers were different... once he downloaded microsoft updates, the code worked like a charm.
Dim db As Dao.Database
Dim rs As Dao.Recordset
Dim qdf As Dao.QueryDef