ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA SQL - variable Source Data... (https://www.excelbanter.com/excel-programming/441248-vba-sql-variable-source-data.html)

SpeeD

VBA SQL - variable Source Data...
 
Hi.

I'm new a this Excel/Sql thing. so bare with me :-)

My my problem is that i need to add several different (variable) SQL queries
to my WB so i´ve add the following with no success:

Cam = ActiveWorkbook.Path & "\" & "JB.xls"
...
..Connection = Array("OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;User
ID=Admin;Data Source=CAM;Mode=Share De"

it only works if i specify the complete path, not variable
..Connection = Array("OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;User
ID=Admin;Data Source=D:\TRABALHOS\2010\Março\JB.xls;Mode=Share De"

How can a make my variable with the Path work?

Thanks for reading this

SpeeD


Bob Phillips[_4_]

VBA SQL - variable Source Data...
 

..Connection = Array("OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;User
ID=Admin;Data Source=" & CAM & ";Mode=Share De"

--

HTH

Bob

"SpeeD" wrote in message
...
Hi.

I'm new a this Excel/Sql thing. so bare with me :-)

My my problem is that i need to add several different (variable) SQL
queries
to my WB so i´ve add the following with no success:

Cam = ActiveWorkbook.Path & "\" & "JB.xls"
..
.Connection = Array("OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;User
ID=Admin;Data Source=CAM;Mode=Share De"

it only works if i specify the complete path, not variable
.Connection = Array("OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;User
ID=Admin;Data Source=D:\TRABALHOS\2010\Março\JB.xls;Mode=Share De"

How can a make my variable with the Path work?

Thanks for reading this

SpeeD




SpeeD

VBA SQL - variable Source Data...
 
Thanks a lot Bob!
It works! :-)

SpeeD

"Bob Phillips" wrote:


..Connection = Array("OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;User
ID=Admin;Data Source=" & CAM & ";Mode=Share De"

--

HTH

Bob

"SpeeD" wrote in message
...
Hi.

I'm new a this Excel/Sql thing. so bare with me :-)

My my problem is that i need to add several different (variable) SQL
queries
to my WB so i´ve add the following with no success:

Cam = ActiveWorkbook.Path & "\" & "JB.xls"
..
.Connection = Array("OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;User
ID=Admin;Data Source=CAM;Mode=Share De"

it only works if i specify the complete path, not variable
.Connection = Array("OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;User
ID=Admin;Data Source=D:\TRABALHOS\2010\Março\JB.xls;Mode=Share De"

How can a make my variable with the Path work?

Thanks for reading this

SpeeD



.



All times are GMT +1. The time now is 04:37 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com