F
FA
Hi Freinds i have the following codes and its giving me the error:
3622: You must use the dbSeeChanges option with OpenRecordset when
accessing a SQL Server table that has an identity column."
The code executes till .Send
and sends email etc etc... but after that there is a flag that i set
which updates the table dbo_SYS_INFO and thats where its gives me the
error. i dont know what i am doing wrong or is there anything else i
can do to avoid this error. please help me out. Thanks
Private Sub Command0_Click()
Dim strTo As String
Dim strSubject As String
Dim varMsg As Variant
Dim varAttachment As Variant
Dim strFlagSQL As String
'Set reference to Outlook
On Error GoTo Errhandler
Dim strBCC As String
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim objOutl As Outlook.Application
'Dim objEml As Outlook.MailItem
Dim I As Integer
Set db = CurrentDb
Set rst = CurrentDb().OpenRecordset("qryContacts", dbOpenSnapshot,
dbSeeChanges)
Set objOutl = CreateObject("Outlook.application")
'Set objEml = objOutl.createItem(olMailitem)
With rst
If .RecordCount > 0 Then
.MoveLast
.MoveFirst
End If
End With
For I = 1 To rst.RecordCount
If Len(rst!PRA_CTAC_NME) > 0 Then
strTo = rst!PRA_CTAC_NME
strSubject = rst!SYS_NME & " " & " " & "PRA Results"
varMsg = emailBody
Dim objEml As Outlook.MailItem
Set objEml = objOutl.CreateItem(olMailItem)
With objEml
.To = strTo
.Subject = strSubject
If Not IsNull(varMsg) Then
.Body = varMsg
End If
.Send
strFlagSQL = "UPDATE dbo_SYS_INFO SET
dbo_SYS_INFO.TEST_STAT_ID = 6 WHERE dbo_SYS_INFO.SYS_ID_CODE =" _
& rst.Fields("SYS_ID_CODE").Value & ";"
db.Execute strFlagSQL, dbFailOnError
Set rst = CurrentDb().OpenRecordset(strFlagSQL,
dbOpenSnapshot, dbSeeChanges)
End With
End If
Set objEml = Nothing
rst.MoveNext
Next I
ExitHere:
Set objOutl = Nothing
'Set objEml = Nothing
Set rst = Nothing
Set db = Nothing
Exit Sub
Errhandler:
MsgBox Err.Number & ": " & Err.Description
Resume ExitHere
'rst.Close
End Sub
3622: You must use the dbSeeChanges option with OpenRecordset when
accessing a SQL Server table that has an identity column."
The code executes till .Send
and sends email etc etc... but after that there is a flag that i set
which updates the table dbo_SYS_INFO and thats where its gives me the
error. i dont know what i am doing wrong or is there anything else i
can do to avoid this error. please help me out. Thanks
Private Sub Command0_Click()
Dim strTo As String
Dim strSubject As String
Dim varMsg As Variant
Dim varAttachment As Variant
Dim strFlagSQL As String
'Set reference to Outlook
On Error GoTo Errhandler
Dim strBCC As String
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim objOutl As Outlook.Application
'Dim objEml As Outlook.MailItem
Dim I As Integer
Set db = CurrentDb
Set rst = CurrentDb().OpenRecordset("qryContacts", dbOpenSnapshot,
dbSeeChanges)
Set objOutl = CreateObject("Outlook.application")
'Set objEml = objOutl.createItem(olMailitem)
With rst
If .RecordCount > 0 Then
.MoveLast
.MoveFirst
End If
End With
For I = 1 To rst.RecordCount
If Len(rst!PRA_CTAC_NME) > 0 Then
strTo = rst!PRA_CTAC_NME
strSubject = rst!SYS_NME & " " & " " & "PRA Results"
varMsg = emailBody
Dim objEml As Outlook.MailItem
Set objEml = objOutl.CreateItem(olMailItem)
With objEml
.To = strTo
.Subject = strSubject
If Not IsNull(varMsg) Then
.Body = varMsg
End If
.Send
strFlagSQL = "UPDATE dbo_SYS_INFO SET
dbo_SYS_INFO.TEST_STAT_ID = 6 WHERE dbo_SYS_INFO.SYS_ID_CODE =" _
& rst.Fields("SYS_ID_CODE").Value & ";"
db.Execute strFlagSQL, dbFailOnError
Set rst = CurrentDb().OpenRecordset(strFlagSQL,
dbOpenSnapshot, dbSeeChanges)
End With
End If
Set objEml = Nothing
rst.MoveNext
Next I
ExitHere:
Set objOutl = Nothing
'Set objEml = Nothing
Set rst = Nothing
Set db = Nothing
Exit Sub
Errhandler:
MsgBox Err.Number & ": " & Err.Description
Resume ExitHere
'rst.Close
End Sub