basil3legs
Programmer
Hi,
I have an Excel spreadsheet which writes loads of data to an Access database and takes ages to run as most of the information is downloaded from tables on the internet. I have found that if I split the spreadsheet in 2 and run both copies at the same time with each doing half the work, it runs a lot quicker as it can access the internet quicker (which takes most of the time). However, every so often one or both copies will crash saying the database is already in use (obviously by the other spreadsheet running). Sometimes both will say the file is in use at the same time and I cannot restart either or even open the database in Access as that says the same, only a reboot will help!!
An example function is:
So the database is only open for a short time for each write (but there are a lot of them!!).
Is there a better way of doing this to prevent this happening as I thought Access could handle multiple writes at the same time.
Thanks in advance.
I have an Excel spreadsheet which writes loads of data to an Access database and takes ages to run as most of the information is downloaded from tables on the internet. I have found that if I split the spreadsheet in 2 and run both copies at the same time with each doing half the work, it runs a lot quicker as it can access the internet quicker (which takes most of the time). However, every so often one or both copies will crash saying the database is already in use (obviously by the other spreadsheet running). Sometimes both will say the file is in use at the same time and I cannot restart either or even open the database in Access as that says the same, only a reboot will help!!
An example function is:
Code:
Function AddData(ID, Name)
Dim cn As ADODB.Connection, rs As ADODB.Recordset, r As Long
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\databases\database.mdb;"
Set rs = New ADODB.Recordset
rs.Open "Table1", cn, adOpenKeyset, adLockOptimistic, adCmdTable
With rs
.AddNew ' create a new record
.Fields("Name") = Name
.Fields("ID") = ID
' add more fields if necessary...
.Update ' stores the new record
End With
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Function
So the database is only open for a short time for each write (but there are a lot of them!!).
Is there a better way of doing this to prevent this happening as I thought Access could handle multiple writes at the same time.
Thanks in advance.