Results 1 to 8 of 8

?

  1. #1
    Mra3134 is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Dec 2016
    Posts
    12

    Angry ?

    Hi there,



    i want to create a query which reads data from a record. for example, suppose i have a table with three fields: [id], [department], [employee]. department field has a lookup type and dets its data from another table. employee field also has the lookup type. but there are a lot of employees and i want to filter them by the value which i had entered in the department field in that particular record. but i dont know how to do it. please help me!

    tnx,
    MRA

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Here's one way:

    BaldyWeb wherecondition

    A parameter query would be another, referring to the form control in the criteria of the query.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,818
    I should mention first that table lookup fields are considered poor practice - unless maybe you're one of a very few that would be using the db, and the data in those fields is rarely changed, and the lookup is for doing things like selecting from a limited controlled list (again, once in a blue moon and by few people). If you can't say that, save yourself some grief and redesign.

    If you insist or just want to learn how to drill down to the value of a lookup field, your query criteria needs to make use of the .value property of these types of field, such as WHERE Empl.Value = forms!myFormName.myControlName where Empl is the name of the field in your query design view. The problem is, what you see in the table is not really there - it is the result of hidden pointers to the source. What's really in the table is the value of the pointer. You are only going to have more trouble with this if what you're doing doesn't meet the test I outlined.

    P.S. a more descriptive title for your post helps people decide on whether or not to pursue it, and helps in future searches.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    More on what Micron is talking about, which I fully agree with:

    http://access.mvps.org/access/lookupfields.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Mra3134 is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Dec 2016
    Posts
    12
    Quote Originally Posted by pbaldy View Post
    Here's one way:

    BaldyWeb wherecondition

    A parameter query would be another, referring to the form control in the criteria of the query.
    Tnx it works! but i cant use it in the lookup field. yet it asks me the value in a combo box.

  6. #6
    Mra3134 is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Dec 2016
    Posts
    12
    okay so what is the best substitution for Lookup function?

  7. #7
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Can you attach the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,445
    sounds like you are taling about cascading combos. But they will only work in a form, not a table our query

Please reply to this thread with any new information or opinions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums