lacampeona
Registered User.
- Local time
- Today, 18:47
- Joined
- Dec 28, 2015
- Messages
- 392
I managed to connect sql server and ms access database and now I am gettting some errror.
"You must use the dbSeeChanges option with OpenRecordSet when accessing a SQL Server table that has an IDENTITY column". This error appears when you open recordset that contains IDENTITY column.
I search on the internet and I find that I have to change and put dbSeeChanges but I dont know the correct syntax
I am sure that this is the problematic line of code:
Set rs = DBEngine(0)(0).OpenRecordset("tblLogDoc", dbOpenDynaset, dbAppendOnly)
Can someone take a look and try to help me or give me advice?
thank you
Here is my module I use:
"You must use the dbSeeChanges option with OpenRecordSet when accessing a SQL Server table that has an IDENTITY column". This error appears when you open recordset that contains IDENTITY column.
I search on the internet and I find that I have to change and put dbSeeChanges but I dont know the correct syntax
I am sure that this is the problematic line of code:
Set rs = DBEngine(0)(0).OpenRecordset("tblLogDoc", dbOpenDynaset, dbAppendOnly)
Can someone take a look and try to help me or give me advice?
thank you
Here is my module I use:
Public Function LogDocOpen(obj As Object) As Long
On Error GoTo Err_Handler
'Purpose: Create a log entry for the form/report being opened.
'Argument: The form or report whose opening we are logging.
'Return: Primary key value of the log entry. Zero on error.
'Usage: For a form, set the On Open property to: =LogDocOpen([Form])
' For a report, set the On Open property to: =LogDocOpen([Report])
Dim rs As DAO.Recordset
Dim lngObjType As Long 'acForm or acReport
Dim strDoc As String 'Name of the form/report
Dim lngHWnd As String 'hWnd of the form/report
If mbLogDox Then
strDoc = obj.Name
lngHWnd = obj.hwnd
Set rs = DBEngine(0)(0).OpenRecordset("tblLogDoc", dbOpenDynaset, dbAppendOnly)
rs.AddNew
rs!OpenDateTime = Now()
rs!CloseDateTime = Null
rs!DocTypeID = DocType(obj)
rs!DocName = strDoc
rs!DocHWnd = lngHWnd
rs!ComputerName = ComputerName()
rs!WinUser = NetworkUserName()
rs!JetUser = CurrentUser()
rs!CurView = CurView(obj)
rs.Update
rs.Bookmark = rs.LastModified
LogDocOpen = rs!LogDocID
rs.Close
End If
Exit_Handler:
Set rs = Nothing
Exit Function
Err_Handler:
Call LogError(Err.Number, Err.Description, conMod & ".LogDocOpen", "Document " & strDoc, False)
Resume Exit_Handler
End Function