I constructed a loader from Excel 2007 into Access 2007. Working in VBA for Excel, the macros finds the database in the same folder as the Loader. Everything works fine on my desktop, but when I am working from a shared network drive I get an error on line:
"rst(Cells(1, j).Value) = Cells(lngRow, j).Value" for whichever line is being loaded.
This is my first post here and I cannot attach the img of error message:
"Run-time error 3251: Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype."
I am pretty familiar with VBA in Excel, but I am relatively new to coding for Access. Please help!
THANK YOU.
"rst(Cells(1, j).Value) = Cells(lngRow, j).Value" for whichever line is being loaded.
This is my first post here and I cannot attach the img of error message:
"Run-time error 3251: Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype."
I am pretty familiar with VBA in Excel, but I am relatively new to coding for Access. Please help!
Code:
Sub AlterOneRecord()
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim fld As ADODB.Field
Dim MyConn
Dim lngRow As Long
Dim lngID As Long
Dim j As Long
Dim sSQL As String
Sheets("Loader").Select
lngRow = 2
lngID = Cells(lngRow, 1).Value
sSQL = "SELECT * FROM Advisers WHERE Adviser_ID = " & lngID
Set cnn = New ADODB.Connection
'sets path for database
MyConn = ThisWorkbook.Path & Application.PathSeparator & TARGET_DB
With cnn
.Provider = "Microsoft.ACE.OLEDB.12.0"
.Open MyConn
End With
Set rst = New ADODB.Recordset
rst.CursorLocation = adUseServer
rst.Open Source:=sSQL, ActiveConnection:=cnn, _
CursorType:=adOpenKeyset, LockType:=adLockOptimistic
'Load all records from Excel to Access.
'j is column
Sheets("Loader").Select
For j = 2 To 49
Select Case Cells(lngRow, j).Value
Case Is = ""
'skip blanks
Case Else
rst(Cells(1, j).Value) = Cells(lngRow, j).Value
End Select
Next j
rst.Update
' Close the connection
rst.Close
cnn.Close
Set rst = Nothing
Set cnn = Nothing
End Sub