I am trying to UPDATE records in an Access table as I screen scrap a string from our legacy system. This code works, but takes 20 minutes to update 460 records.
I am not very good at SQL, but made this atempt at writing to the first field. I get an error 3085 Undefined funciton 'arrData' in expression.
Thank you in advance for any suggestions.
You don't know what you don't know...
Code:
Sub RPHI_Retrieve()
Dim rs As DAO.Recordset
Dim db As DAO.Database
Dim ws As DAO.Workspace
Dim dbPath As String
Dim strReadline As String
Dim arrData() As String
dbPath = "S:\Pharmacy General\Databases Automation\Databases\Test\Test.accdb"
Set ws = DBEngine.Workspaces(0)
Set db = ws.OpenDatabase(dbPath)
Set rs = db.OpenRecordset("tblTemp", dbOpenTable)
'Set rs = db.OpenRecordset("SELECT * FROM tblTemp")
'strReadline from screen scraping delimited by the pipe character
arrData = Split(strReadline, "|")
rs.MoveFirst
Do Until rs.EOF
If rs!Number = arrData(0) Then
rs.Edit
rs!Resources1 = arrData(1)
rs!Resources2 = arrData(2)
rs!Resources3 = arrData(3)
rs!Resources4 = arrData(4)
rs!Resources5 = arrData(5)
rs.Update
End If
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
Set ws = Nothing
End Sub
I am not very good at SQL, but made this atempt at writing to the first field. I get an error 3085 Undefined funciton 'arrData' in expression.
Code:
' same dims as first example
arrData = Split(strReadline, "|")
db.Execute "UPDATE tblRPHITemp SET Resources1 = arrData(1) WHERE Number = arrData(0);"
'& "SET tblTemp.Resources1 = arrData(1) " _
'& "SET tblemp.Resources2 = arrData(2) " _
'& "SET tblTemp.Resources3 = arrData(3) " _
'& "SET tblTemp.Resources4 = arrData(4) " _
'& "SET tblTemp.Resources5 = arrData(5) " _
'& "WHERE tblTemp.Number = ArrData(0);"
Thank you in advance for any suggestions.
You don't know what you don't know...