Passing variable to Connection (ODBC connection)

Jack_881

New Member
Joined
Sep 11, 2020
Messages
16
Office Version
  1. 2019
Platform
  1. Windows
Hi Experts

I have a spreadsheet that connects to an external source using ODBC using the connection from the ODBC 64-bit App. This data source imports information based on the LOTID. Currently the only way I know to change the LOTID is to go into Power Query Editor and click Source which shows the SQL statment being used to retrieve the data. I manually change the WHERE statment to the LOTID that I want to import.

Whilst this works, I would rather be able to pass a variable to the Connection and it either changes the LOTID in the SQL statment or just imports the entire SQL statment including the new LOTID. The only thing that changes in the SQL statement is the LOTID. Example:

Select
Reports.*,
Lots.Customer,
Lots.Description

FROM
Units_Reports Reports

INNER JOIN

Lots ON Reports.LotID = Lots.LotID

WHERE Reports.LotID = 1238

Not sure if an elegant solution is possible.

Cheers

Jack
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,214,920
Messages
6,122,279
Members
449,075
Latest member
staticfluids

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