Execute MS Access Query (Database on server)

Beginner99

New Member
Joined
Dec 3, 2020
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Dear Users,

I got into a problem and I do not how to solve the problem. I got the code below that runs a Query defined in an MS Access Database. When I run this code with the database local there is no problem. However when I put the database on a shared server the two bold lines takes an eternity to execute, especially the last one.

Can I do this in another way that reduce the time? We are taking about minutes to execute. My connection to the server is around 20mbit/s. I'm using window 10, Access 2016.

Best Regards

VBA Code:
    Dim objAccess As Object
    Dim RecordSet As Object
           
    ' Open
    Set objAccess = CreateObject("access.application")
    objAccess.Visible = False
[B]    objAccess.OpenCurrentDatabase GetDataBaseName, , Password
    Set RecordSet = objAccess.CurrentDb.OpenRecordset(Query.Value, dbOpenSnapshot)[/B]
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

ranman256

Well-known Member
Joined
Jun 17, 2014
Messages
1,980
Access has a large footprint, and you're running it from excel and running on a server.
dump the 'load access' routine and use Excel connection to connect to the db without opening the Access app.

Just grab the data. much faster.

No connect code needed but similar in code:
Code:
dim sSql as string
dim conn As New ADODB.Connection

sSql = "select * from table"
sConnStr = "Driver=" & vDriver & ";Server=" & vSvr & ";Database=" & pvDb & ";Trusted_connection=Yes;ConnectionTimeOut = 5"
conn.ConnectionString = sConnStr
conn.Open

Set Rst = conn.Execute(sSql)
 

Watch MrExcel Video

Forum statistics

Threads
1,130,033
Messages
5,639,654
Members
417,102
Latest member
bcselect

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top