Morning!
I had a database which I have recently switched over to use the data from a SharePoint site. On the one form I had VBA to add an entry to the table it looks up from in the entry is not in the list (code below) and it was working fine.
However after making the switch to the SharePoint linked tables I get an error "You must use the dbSeeChanges option with OpenRecordSet when accessing a SQL Server table that has an IDENTITY column"
Now I know it goes in the initial code somewhere but where?
Thanks
Kathie
*************************************
Private Sub Parent_Company_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_ErrorHandler
' provide text constants to reduce text later and allow for faster execution
' due to added speed from the compilation of constants
Const Message1 = "The data you have entered is not in the current selection."
Const Message2 = "Would you like to add it?"
Const Title = "Unknown entry..."
Const NL = vbCrLf & vbCrLf
' database and recordset object variables
Dim db As DAO.Database
Dim rs As DAO.Recordset
' show message box and evaluate if the user has selected Yes or No
If MsgBox(Message1 & NL & Message2, vbQuestion + vbYesNo, Title) = vbYes Then
' open a connection to the current database
Set db = CurrentDb
Set rs = db.OpenRecordset("Access_Parent_Company")
' using the recordset object
With rs
.AddNew ' prepare to add a new record
.Fields("Access_Parent_Company") = NewData ' add unfound data into field
.Update ' update the table
.Close ' close the recordset object
End With
Response = acDataErrAdded ' confirm record added
Else
Me.Parent_Company.Undo ' clear the entry in the combobox
Response = acDataErrContinue ' confirm the record is not allowed
End If
Exit_ErrorHandler:
' de-initialise our object variables
Set rs = Nothing
Set db = Nothing
Exit Sub
Err_ErrorHandler:
' display error message and error number
MsgBox Err.Description, vbExclamation, "Error #" & Err.Number
Resume Exit_ErrorHandler
End Sub
I had a database which I have recently switched over to use the data from a SharePoint site. On the one form I had VBA to add an entry to the table it looks up from in the entry is not in the list (code below) and it was working fine.
However after making the switch to the SharePoint linked tables I get an error "You must use the dbSeeChanges option with OpenRecordSet when accessing a SQL Server table that has an IDENTITY column"
Now I know it goes in the initial code somewhere but where?
Thanks
Kathie
*************************************
Private Sub Parent_Company_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_ErrorHandler
' provide text constants to reduce text later and allow for faster execution
' due to added speed from the compilation of constants
Const Message1 = "The data you have entered is not in the current selection."
Const Message2 = "Would you like to add it?"
Const Title = "Unknown entry..."
Const NL = vbCrLf & vbCrLf
' database and recordset object variables
Dim db As DAO.Database
Dim rs As DAO.Recordset
' show message box and evaluate if the user has selected Yes or No
If MsgBox(Message1 & NL & Message2, vbQuestion + vbYesNo, Title) = vbYes Then
' open a connection to the current database
Set db = CurrentDb
Set rs = db.OpenRecordset("Access_Parent_Company")
' using the recordset object
With rs
.AddNew ' prepare to add a new record
.Fields("Access_Parent_Company") = NewData ' add unfound data into field
.Update ' update the table
.Close ' close the recordset object
End With
Response = acDataErrAdded ' confirm record added
Else
Me.Parent_Company.Undo ' clear the entry in the combobox
Response = acDataErrContinue ' confirm the record is not allowed
End If
Exit_ErrorHandler:
' de-initialise our object variables
Set rs = Nothing
Set db = Nothing
Exit Sub
Err_ErrorHandler:
' display error message and error number
MsgBox Err.Description, vbExclamation, "Error #" & Err.Number
Resume Exit_ErrorHandler
End Sub