run time error 3251, after upsizing to SQL Server (1 Viewer)

cursedeye

Registered User.
Local time
Yesterday, 20:24
Joined
Oct 7, 2009
Messages
50
Runtime error 3251: operation is not supported for this type of object.

Option Compare Database

Private Sub ReadInboxDone()
Dim TempRst As DAO.Recordset
Dim rst As DAO.Recordset
Dim OlApp As Outlook.Application
Dim Inbox As Outlook.MAPIFolder
Dim InboxItems As Outlook.Items
Dim Mailobject As Object
Dim db As DAO.Database
Dim dealer As Integer

On Error GoTo ErrorHandler

DoCmd.RunSQL "Delete * from tbl_outlooktempFinish"
Set db = CurrentDb

Set OlApp = CreateObject("Outlook.Application")
Set Inbox = OlApp.GetNamespace("Mapi").GetDefaultFolder(olFolderInbox)
Set TempRst = CurrentDb.OpenRecordset("tbl_OutlookTempFinish", dbOpenSnapshot, dbSeeChanges)
Set InboxItems = Inbox.Items

For Each Mailobject In InboxItems
If Mailobject.UnRead Then
'split fresh and old-replied part in email body.
Position = 0
Do Until (Split(Mailobject.Body, vbCrLf)(Position) <> "")
Position = Position + 1
Loop
'only read the first line of fresh part of an email.
If Split(Mailobject.Body, vbCrLf)(0) Like "*Done*" Or Split(Mailobject.Body, vbCrLf)(0) Like "*Complete*" Or Split(Mailobject.Body, vbCrLf)(0) Like "*repaired*" Then

With TempRst
.AddNew
!Subject = Mailobject.Subject
!Sender = Mailobject.SenderName
!To = Mailobject.To
!Body = Mailobject.Body
!DateSent = Mailobject.SentOn
!DateReceived = Mailobject.ReceivedTime
.Update

Mailobject.UnRead = False

End With
End If
End If
Next

ErrorHandler:
Set OlApp = Nothing
Set Inbox = Nothing
Set InboxItems = Nothing
Set Mailobject = Nothing
Set TempRst = Nothing

End Sub


debugging says ".AddNew" is where the problem occurs.

Can anyone tell me how to fix this?

Thanks
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 16:24
Joined
Aug 30, 2003
Messages
36,140
dbOpenSnapshot opens a read only recordset. Try dbOpenDynaset.
 

cursedeye

Registered User.
Local time
Yesterday, 20:24
Joined
Oct 7, 2009
Messages
50
Thank you buddy. I got it working.
 

Users who are viewing this thread

Top Bottom