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(wkImportTable)

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
                    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
                .ActiveCell.Offset(1, 0).Activate
                vRow = vRow + 1
                If .ActiveCell.Value = "" Then Exit Do
    End With
End Sub

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:

Set rs = CurrentDb.OpenRecordset(wkImportTable, , dbseechanges)
mlcktmguyAuthor Commented:
Thank you but I still get the same error on the revised statement.
Rey Obrero (Capricorn1)Commented:
what error are you getting now?


Set rs = CurrentDb.OpenRecordset(wkImportTable,dbOpenTable, dbseechanges)


Set rs = CurrentDb.OpenRecordset(wkImportTable,dbOpenDynaset, dbseechanges)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mlcktmguyAuthor Commented:
Thanks, the first suggestion in your reply'
 Set rs = CurrentDb.OpenRecordset(wkImportTable,dbOpenDynaset, dbseechanges)
generated a 3219 Invalid operation error.

The second

Set rs = CurrentDb.OpenRecordset(wkImportTable,dbOpenDynaset, dbseechanges)

resolved the issue.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.