ANDYB0ARDMAN
New Member
- Joined
- Jun 23, 2019
- Messages
- 5
Hi
I have two excel files stored in Dropbox - one a database that is not opened by users and the other a tool that runs two query tables from the database and is supposed to refresh the query tables on auto_open by setting the connectionstring to the users filepath to find the data source - database file.
Using Query tables is new for me so I'm struggling a bit!
Here's where I am up to at the moment - this runs and then throws an error on the last line.
When I go into query properties I see the data source has not changed.
I've scoured the forums and see references to ADODB.Connection etc but the syntax doesn't work for me.
I'm at a loss and getting frustrated....I don't code very often nowadays and I just need to get this done - everything else works fine.....
All help gratefully received.
Thanks Andy
I have two excel files stored in Dropbox - one a database that is not opened by users and the other a tool that runs two query tables from the database and is supposed to refresh the query tables on auto_open by setting the connectionstring to the users filepath to find the data source - database file.
Using Query tables is new for me so I'm struggling a bit!
Here's where I am up to at the moment - this runs and then throws an error on the last line.
When I go into query properties I see the data source has not changed.
Code:
Sheets("Table-Data").Select
Range("a1").Select
Dim username As String
username = Environ("username")
Dim q As WorkbookQuery
For Each q In ThisWorkbook.Queries
Connectionstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\" & Environ("UserName") & "\Dropbox\Delphy - Reports\Crop Chemical Database;Extended Properties=Excel 12.0 Macro;HDR=YES;"
Next
ActiveWorkbook.connections("Query - Data (13)").refresh
I've scoured the forums and see references to ADODB.Connection etc but the syntax doesn't work for me.
I'm at a loss and getting frustrated....I don't code very often nowadays and I just need to get this done - everything else works fine.....
All help gratefully received.
Thanks Andy