Using a Form Field to Control a Query

Centrican

Board Regular
Joined
Dec 20, 2006
Messages
130
I'm trying to use a form to control what query to run.

I hav a form with a lookup field allowing the user to select a site type from a list. When selected, I want to use this field as a criteria in a query (already written).

It doesn't work if I use the following format:

"=[forms]![frm_override_queries]![sitetypeselector]"

It says it doesn't recognise 'forms!frm_override_queries!sitetypeselector' as a falid field.

If I set the query criteria to be '[test]' and type the site type in freeform it works no problem, and I can't for the life of me work out what I'm doing wrong.

Any hints?
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Is your sitetypeselector field on a subform? If so, you'll need to change your criteria to [Forms]![xParentForm]![xSubform].[Form].[sitetypeselector] --- just change xParentForm to the parent form's name and xSubform to the subform's name. Also, try your criteria without the equal sign.
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,392
Members
449,081
Latest member
JAMES KECULAH

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