How to delete unused parameter?

zovche

Board Regular
Joined
Mar 21, 2013
Messages
125
I'm using external connections and SQL. At first I had four parameters (in SQL I have like table1.field1 = ?), then I needed only three parameters so I deleted one from SQL. However it still asks me to enter value or reference for that deleted Parameter. It won't recognize that there's only 3 parameters now. Does anyone know how to delete parameters completely?
 
Solution found!
Select a cell in your query output. Depending on the format of your query, you may find you need to use a different syntax than that below.
Go to VBA and go to the immediates window.
Type:

set qry = selection.listobject.querytable
qry.parameters.delete

Note - this will delete all your parameters and you will then have to go re-set the ones you want. The next time you refresh, Excel will prompt you for the settings.

I would have thought you could, for example, do qry.parameters(5).delete, but I could not find a way to make that work

it is also helpful to use qry.parameters(1).name = "StartDate" or whatever you want, altho if you re-order or restructure your query, "StartDate" is always going to be the first Parameter, even if you use it for a different purpose, until you rename it.
 
Upvote 0

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Forum statistics

Threads
1,214,583
Messages
6,120,377
Members
448,955
Latest member
BatCoder

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