Consulting

Results 1 to 4 of 4

Thread: Solved: Query Criteria

  1. #1

    Solved: Query Criteria

    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[VBA]=Me.WCMan[/VBA] 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

  2. #2
    VBAX Regular jadedata's Avatar
    Joined
    May 2004
    Location
    Eastport, Maine
    Posts
    13
    Location
    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.)
    -j-

  3. #3
    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!

  4. #4
    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.
    [VBA][Forms]![Job Order Form]![Ant1Qry subform].[Form]![LineQry subform].[Form]![WCMan][/VBA]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •