Query based on changing field and criteria - help please!

tmc

Registered User.
Local time
Today, 17:23
Joined
Nov 10, 2009
Messages
13
Hello,

Could anyone please help with a query I have that doesn't work!

Basically I have a form and want the query based on the input of two combo boxes

In the 'field' area I have put:

Expr1: [Forms]![my combo box form name]![product category combo box]

and in the criteria section I have put:

[Forms]![my combo box form name]![product type combo box]

So if for example I put 'apples' intp the product combo box and 'green' into the type combo box on my form, I wish the query to filter out first all records with the field 'apples' and then those apples that also have the type field as 'green'. I can get the query to work with the expression in either the field or criteria section but not both???

If anyone could help i'd really appreciate it, I'm a learning newbie so please go easy!

Thanks for reading.
 
I presume that you mean that the recordsource of the form is a query and you want to filter that recordsource by 2 combox box controls on the form. TYhose combo boxes are not necessarily bound to the recordsource

Build your query in the QBE window, filtering the appropraite fields by a combo box references. Your form is a bound form with that query as the recordsource.

Put the combo boxes in the header of the form, if they are not bound to the recordsource. On the after update event of each such combo box requery the form and your form should appriopriately tumble.

Take a look at (search for) the "Hungarian notation" to see a good method for naming objects and controls. Control or object name should unambiguously tell you what that control or object is. What's the data type of a control named "start date"? Is it a datre or a string? dtstart would mean a date, txtstart would mean a string. Names should not have embedded spaces, ever! With then, you must enclose same in brackets and you'll forget to be consistent in using spaces. No spaces saves a lot of keystrocks. Judicious use of capital letters makes name readeable.
 

Users who are viewing this thread

Back
Top Bottom