PDA

View Full Version : Solved: Query Criteria



JustJerry
09-08-2005, 10:20 PM
I have created several queries in a project I am working on, but I am now trying to create one specifying certain criteria...something I have not done before yet.

I have a subform that this query is to be used for, and subform is called "LineSub". LineSub's data source is also built on a query called "LineQry".

On this subform, I have a combobox that the user selects a certain product, and after choosing a product, a control named "WCMan" is automatically filled in with the manufacturer.

I have a second combobox that I am trying to use a query to list ONLY matching products based on the manufacturer listed in the control "WCMan"

I have tried using=Me.WCMan in the 'criteria' portion of the second query I am working on, but when I open up the forms, I get a message box asking for the value of Me.WCMan. If I fill in the message box, the combobox does list what I am looking for.

Can someone clue me in on how to have the query work correctly, and how to type criteria based on other values in a from?

Thank you

Jerry

jadedata
09-09-2005, 07:12 AM
first,... start applying control type prefixes on your form controls to eliminate possible confusion with field names in tables. I use "cbo" on the front of a combobox control name followed by the name of the field it is bound to.... ie "cboWCMan"

the query for the dependent cbo is not aware of the form being open or available at run time,... you must specify it by using the complete object lineage

SELECT This, That
FROM ATableName
WHERE ([That] = [forms].[someformname].[WCMan])

the form must be open or you will get an error
the datatypes must be consistant or at least acceptable or you will get an error
you must vote republican or you will get an error (but only if you live in florida.)

JustJerry
09-09-2005, 05:33 PM
Thank you for the input. I will try and work on this during the weekend.

P.S. I like the added touch on the very last line of your message, pretty witty!

JustJerry
09-09-2005, 08:24 PM
It must be something about me just posting in here, because after pondering what you said, I finally figured out how to make it work. This is what I ended up with that finally worked correctly.
[Forms]![Job Order Form]![Ant1Qry subform].[Form]![LineQry subform].[Form]![WCMan]