Runtime Error 438 Object doesn't support this property or object

I am using the following code:
Private Sub btnNewMail_Click()
    Dim colItems        As Outlook.Items
    Dim objCurrentItem  As Object
    Dim strSQL          As String
    Dim dbs             As Database
    Dim tdf             As TableDef
    Dim rst             As DAO.Recordset
    Dim intDuplicates   As Integer
    Dim intI            As Integer
    Dim Attachment9     As String
    Dim dummy As String
On Error GoTo Error_btnNewMail_Click
    Set colItems = GetMailboxNetworkInput(Me.cmbMap, Me.cmbFolder)
    If colItems Is Nothing Then
        MsgBox "No items found"
        ' Return Database object variable pointing to current database.
        Set dbs = CurrentDb
        ' Return TableDef object variable pointing to Mail table.
        Set rst = dbs.OpenRecordset("Mail")
        ' Add to table Mail
        'DoCmd.Hourglass True
        DoCmd.SetWarnings False
        For Each objCurrentItem In colItems
            If Not fncMailExist(objCurrentItem.EntryID) Then
                rst!EntryID = objCurrentItem.EntryID
                rst!ReceivedTime = objCurrentItem.ReceivedTime
                rst!Subject = objCurrentItem.Subject
                rst!SenderName = objCurrentItem.SenderName
                rst!CC = objCurrentItem.CC
                rst!Body = fncReplaceTabs(objCurrentItem.Body)
                rst!Attachments = objCurrentItem.Attachments.Count
                'Save attachments in c:\temp
                Attachment9 = ""
                If objCurrentItem.Attachments.Count > 0 Then
                    For intI = 1 To objCurrentItem.Attachments.Count
                        objCurrentItem.Attachments.Item(intI).SaveAsFile ("T:\Cost Mailbox\Mail Attachments\" & objCurrentItem.Attachments.Item(intI))
                        Attachment9 = Attachment9 & "," & objCurrentItem.Attachments.Item(intI)
                    Next intI
                End If
                rst!AttachmentsName = Mid(Attachment9, 2)
                intDuplicates = intDuplicates + 1
                If intDuplicates = 1 Then MsgBox "Duplicate emails were found.  These items will not be imported into the log."
            End If
        Next objCurrentItem
        DoCmd.SetWarnings True
        'DoCmd.Hourglass False
        Set rst = Nothing
        Set dbs = Nothing
    End If
    GoTo Exit_btnNewMail_Click

Select Case Err
    Case 3022, 6
        Resume Next
    Case Else
        MsgBox "Error: " & Err.Number & vbCrLf & Err.Description
End Select

MsgBox "Emails have been logged into the Database.", vbOKOnly, "Get Emails"

End Sub

When I click on the button that runs this, I get "Error 438 Object doesn't support this property or object".  Can someone tell me why this is happening and how to fix it?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Leigh PurvisDatabase DeveloperCommented:
You really need to (temporarily) remove your error handling to determine where the error is occuring.
Just comment out the line
'On Error GoTo Error_btnNewMail_Click

It could be occuring in your called procedures
GetMailboxNetworkInput, fncMailExist or fncReplaceTabs
cobiannaAuthor Commented:
The error occured at the following line:
     rst!ReceivedTime = objCurrentItem.ReceivedTime

Any suggestions?
Leigh PurvisDatabase DeveloperCommented:
So I presume that GetMailboxNetworkInput returns the collection of mails from a specific folder in Outlook?
What is the code in GetMailboxNetworkInput ?

Is there a particular reason that you declare
Dim objCurrentItem  As Object
instead of
Dim objCurrentItem  As Outlook.MailItem

Does the collection not iterate if you do that?
cobiannaAuthor Commented:
Here is the code for "GetMailboxNetworkInput":
Function GetMailboxNetworkInput(strMapNameLike As String, strFolderName As String) As Outlook.Items
    ' This procedure returns the items of the Outlook mailbox folder.                            *
    ' That is identified by:                                                                     *
    ' strMapNameLike = unique "Instr" part of MAP from outlook                                   *
    ' strFoldername  = name of folder                                                            *
    ' These variables have been specified to be able to identify the "Input" folder of the       *
    ' correct mailbox                                                                            *
    ' For the use within this application normally "Network" and "Input" will be specified       *
    Dim colMaps     As Outlook.Folders
    Dim colFolders  As Outlook.Folders
    Dim fldFolder   As Outlook.MAPIFolder
    Dim fldMap      As Outlook.MAPIFolder
    ' Use the InitializeOutlook procedure to initialize global
    ' Application and NameSpace object variables, if necessary.
    If golApp Is Nothing Then
        If InitializeOutlook = False Then
            MsgBox "Unable to initialize Outlook Application " _
                & "or NameSpace object variables!"
            Exit Function
        End If
    End If
    Set colMaps = gnspNameSpace.Folders
    For Each fldMap In colMaps
        If InStr(fldMap.Name, strMapNameLike) > 0 Then
            Set colFolders = fldMap.Folders
            For Each fldFolder In colFolders
                If fldFolder.Name = strFolderName Then
                    Set GetMailboxNetworkInput = fldFolder.Items
                    Exit Function
                End If
            Next fldFolder
        Set GetMailboxNetworkInput = Nothing
        End If
    Next fldMap
End Function

I did not create this code so I'm not sure why they would have used As Object instead of As Outlook.MailItem.
Leigh PurvisDatabase DeveloperCommented:
Try switching the declaration for now - see if it highlights the problem any earlier (when you compile or first run it).

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.