Database query won't refresh from combobox criteria

fprzekop

Board Regular
Joined
Jun 25, 2002
Messages
74
I have a database query (Excel 2003) that is setup with a parameter. The parameter is linked to a cell value, and the cell value is populated from a combobox.

The idea is.... select item from combobox, parameter cell changes, databasequery executes. Interestingly, the first time I select a particular combobox item, the database query executes. If I later select the same item, the query does not execute.

I also find that if I enter a value manually in the parameter cell the query executes. There appears to be a bug when using a combobox to populate the parameter cell for the query. Suggestions appreciated!

(I thought I could do this without VBA.... perhaps not)
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Hello there,

The combo changing value will not trigger the the worksheet_change event.

2 ways I can think off. I suppose the linked cell of the combo is B1

Try to force the worksheet_change to happen

Private Sub ComboBox1_Change()
Dim rangi As Range
Set rangi = Range("b1")
Worksheet_Change rangi
End Sub


The other option you can try is [change sheetname and query name to corresponding]

Private Sub ComboBox1_Change()
sheet1.querytables("myquery").refresh
End Sub
 
Upvote 0
Thanks Francois, I suspected as much. Forcing the query refresh is the approach I'll take.
- Fred
 
Upvote 0

Forum statistics

Threads
1,214,819
Messages
6,121,729
Members
449,049
Latest member
MiguekHeka

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