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

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
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)
 
Upvote 0

Forum statistics

Threads
1,215,022
Messages
6,122,716
Members
449,093
Latest member
Mnur

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
Back
Top