Forum Discussion
ODBC data connection with parameter from drop down
- Sep 10, 2020
SergeiBaklan thank you that is exactly it! I added the line you mentioned and it works! For anyone else looking for this solution, here it is:
let pperiod = Excel.CurrentWorkbook(){[Name="reneirs_pperiod"]}[Content]{0}[Column1], pperiod_text = Text.From(pperiod), Source = Odbc.Query("dsn=PASTEL.odbc", "select * from LedgerTransactions where PPeriod = " & pperiod_text) in Source
Not clear from the screenshot, it could be if [Column1] is missed on first step. What do you see as result if you stay on first step, is it 108?
In any case please add one more step in the middle, I forgot you parameter in Excel is number, we need to convert it to text
parameter = Text.From(PPeriod_parameter),
and use the latest in query string.
SergeiBaklan thank you that is exactly it! I added the line you mentioned and it works! For anyone else looking for this solution, here it is:
let
pperiod = Excel.CurrentWorkbook(){[Name="reneirs_pperiod"]}[Content]{0}[Column1],
pperiod_text = Text.From(pperiod),
Source = Odbc.Query("dsn=PASTEL.odbc", "select * from LedgerTransactions where PPeriod = " & pperiod_text)
in
Source
- Michelle99Sep 10, 2020Brass Contributor
I have one Laaaaast Question SergeiBaklan ... Every time I select a new PPeriod in my yellow dropdown, I have to go and refresh my query for the new data to be reflected in the table. Question: Am I correct that I'll need to write some VBA code to "force" automatic query refresh every time my user selects a new PPeriod?
- SergeiBaklanSep 10, 2020Diamond Contributor
Great to know it finally works, thanks for the result sharing.
Yes, if automatic upon parameter is changed that's VBA. Can't advise with concrete code, but you may google for the pattern or ask as separate question this forum people.
- MaxMilankaDec 03, 2021Copper Contributor
SergeiBaklan Michelle99 This has been very useful so far. H'ever, I'm having an error like in the screenshot and will you able to help? Unable to convert to text as well. Appreciate your help.