Hi,
My first post here. Please be lenient...
I am trying to pass an object to a function. I am running through an outlook inbox, and I need to pass an email as an object. The line where I pass the object to the function causes Access to throw me an error: "run time error 424: object required".
I am confused. I clearly pass an object, and the VBA complains that an object is required. Can somebody shed some light on this?
Private Sub ReadInbox()
Dim OlApp As Outlook.Application
Dim Inbox As Outlook.MAPIFolder
Dim InboxItems As Outlook.Items
Dim mailObject As Object
Set OlApp = CreateObject("Outlook.Application")
Set Inbox = OlApp.GetNamespace("Mapi").GetDefaultFolder(olFolderInbox)
Set TempRst = CurrentDb.OpenRecordset("abstracts")
Set InboxItems = Inbox.Items
For Each mailObject In InboxItems
' the next line causes the error
checkTriggerPresent (mailObject)
Next
Set OlApp = Nothing
Set Inbox = Nothing
Set InboxItems = Nothing
Set mailObject = Nothing
Set TempRst = Nothing
Set atmt = Nothing
End Sub
Function checkTriggerPresent(mailObject As Object) As String
msgbox ("It doesn't work")
End Function
My first post here. Please be lenient...
I am trying to pass an object to a function. I am running through an outlook inbox, and I need to pass an email as an object. The line where I pass the object to the function causes Access to throw me an error: "run time error 424: object required".
I am confused. I clearly pass an object, and the VBA complains that an object is required. Can somebody shed some light on this?
Private Sub ReadInbox()
Dim OlApp As Outlook.Application
Dim Inbox As Outlook.MAPIFolder
Dim InboxItems As Outlook.Items
Dim mailObject As Object
Set OlApp = CreateObject("Outlook.Application")
Set Inbox = OlApp.GetNamespace("Mapi").GetDefaultFolder(olFolderInbox)
Set TempRst = CurrentDb.OpenRecordset("abstracts")
Set InboxItems = Inbox.Items
For Each mailObject In InboxItems
' the next line causes the error
checkTriggerPresent (mailObject)
Next
Set OlApp = Nothing
Set Inbox = Nothing
Set InboxItems = Nothing
Set mailObject = Nothing
Set TempRst = Nothing
Set atmt = Nothing
End Sub
Function checkTriggerPresent(mailObject As Object) As String
msgbox ("It doesn't work")
End Function