mlcktmguy
asked on
Read SQL Table with DAO, Error 3627
I have a piece of logic the worked perfectly when reading data from a spreadsheet into an Access table (wkImportTable).
I move wkImportTable from Access to a SQL database and now I'm getting an error on this statement
Set rs = CurrentDb.OpenRecordset(wk ImportTabl e)
It is an error 3627, must use dbSeeChanges option when accessing SQL Server table that has an identity column.
The table does have an 'ID' column so I understand that,
How to I revise the logic to include the dbSeeChanges option?
Here is the code segment:
I move wkImportTable from Access to a SQL database and now I'm getting an error on this statement
Set rs = CurrentDb.OpenRecordset(wk
It is an error 3627, must use dbSeeChanges option when accessing SQL Server table that has an identity column.
The table does have an 'ID' column so I understand that,
How to I revise the logic to include the dbSeeChanges option?
Here is the code segment:
Sub ImportRecords(passedSpreadandLoc As String, passedImportToTable As String)
Dim wkSpread As String
Dim wkImportTable As String
'
wkImportTable = passedImportToTable ' "EE_Import"
wkSpread = passedSpreadandLoc ' wkSpread = "C:\My Documents\Access_Databases\JordanDelinq\FromJoe_LegalStatusSpreads\EETestVers.xls"
'
clearTable wkImportTable
Dim xlFile As String
xlFile = wkSpread 'CurrentProject.Path & "\EETestVers.xls"
Dim rs As DAO.Recordset, xlObj As Object, j As Integer
Dim vRow As Integer, colCnt As Integer
colCnt = 12: vRow = 6
Set rs = CurrentDb.OpenRecordset(wkImportTable)
Set xlObj = CreateObject("excel.application")
xlObj.Workbooks.Open xlFile
With xlObj
.Visible = True
' .worksheets("active files").Select ' don't hard code the description
.worksheets(1).Select ' always the first tab
.cells(vRow, 2).Select
Do
rs.AddNew
rs!F1 = .cells(vRow, 1).Value
rs!F2 = .cells(vRow, 2).Value
rs!F3 = .cells(vRow, 3).Value
rs!F4 = .cells(vRow, 4).Value
rs!F5 = .cells(vRow, 5).Value
rs!F6 = .cells(vRow, 6).Value
rs!F7 = .cells(vRow, 7).Value
rs!F8 = .cells(vRow, 8).Value
rs!F9 = .cells(vRow, 9).Value
rs!F10 = .cells(vRow, 10).Value
rs!F11 = .cells(vRow, 11).Value
rs!F12 = .cells(vRow, 12).Value
rs.Update
.ActiveCell.Offset(1, 0).Activate
vRow = vRow + 1
If .ActiveCell.Value = "" Then Exit Do
Loop
End With
xlObj.Quit
rs.Close
End Sub
ASKER
Thank you but I still get the same error on the revised statement.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, the first suggestion in your reply'
Set rs = CurrentDb.OpenRecordset(wk ImportTabl e,dbOpenDy naset, dbseechanges)
generated a 3219 Invalid operation error.
The second
Set rs = CurrentDb.OpenRecordset(wk ImportTabl e,dbOpenDy naset, dbseechanges)
resolved the issue.
Set rs = CurrentDb.OpenRecordset(wk
generated a 3219 Invalid operation error.
The second
Set rs = CurrentDb.OpenRecordset(wk
resolved the issue.
Set rs = CurrentDb.OpenRecordset(wk