Results 1 to 8 of 8
  1. #1
    gully300 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2011
    Posts
    4

    list lookup query


    i'm trying to setup a conditional lookup in a query, i have table
    Catagories(PCVCatagory,CatNo,Options)
    and query
    [Classifier Synnex](1,2,PCVCatagory,Cat1,Cat2,.....,item)
    what i'm trying to achieve is lookup tables for Cat1-Cat5, the lookup lists coming from
    Catagories.Options
    when
    Catagories.PCVCatagory=[Classifier Synnex].PCVCatagory
    and
    Catagories.CatNo=[Classifier Synnex].(1 for Cat1, 2 for Cat2......)

    what i have so far

    SELECT Catagories.Options
    FROM Catagories
    WHERE Catagories.CatNo="1" And Catagories.PCVCatagory=[Classifier Synnex]![PCVCatagory];


    whats not happeneing is [Classifier Synnex]![PCVCatagory] isn't getting the value of Synnex.PCVCatagory for the current row i'm workin on, i'v been running in circles and no matter what i google or how i phrase it wont work.

    any help greatly appreciated

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Include a JOIN clause of the table Catagories and query Classifier Synnex

    INNER JOIN Catagories.PCVCatagory=[Classifier Synnex]![PCVCatagory]

    I am guessing INNER will work to properly relate these objects. No need for this expression in the WHERE.

    BTW, correct spelling is Category
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    gully300 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2011
    Posts
    4
    I'm not quite sure where the INNER is ment to go but i dont think thats quite what i need either, the expression works fine if i specify the variable manually, like cpu...

    SELECT Catagories.Options
    FROM Catagories
    WHERE Catagories.CatNo="1" And Catagories.PCVCatagory="CPU";

    it just isn't pulling it out of the query, also a bit more info on the table its layed out

    CPU,1,1156,##
    CPU,1,1366,##
    CPU,1,1155,##
    CPU,2,2.6G,##
    CPU,2,2.8G,##
    CPU,2,3.0G,##
    ## are the autonumber and "primary key"

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    That works because you offer the query a literal value as the criteria.

    When you have =[Classifier Synnex]![PCVCatagory] the criteria is a field of table, not a specific value.

    After looking at your query again, I can now see that a join probably won't accomplish anything. The PCVCatagory value must be a parameter input, by reference to a field in current record or prompt to user.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    gully300 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2011
    Posts
    4
    ok so how do i reference a field in the current record, because thats one of the things i was and still am chasing in circles

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    I don't normally setup lookups in tables or queries, only in combo and list boxes on forms and that is how I was approaching this. I finally realized you must be trying to do this directly in query so I gave it a try and it doesn't work. I set up a form bound to Classifier Synnex, created combobox bound to PCVCatagory and named it cbxPCVCatagory, created combobox bound to Cat1 and RowSource of:
    SELECT Option FROM Catagories WHERE CatNo="1" AND PCVCatagory=[cbxPCVCatagory];
    That works.

    Will need code (I use VBA only) to requery Cat1 combobox (and the other comboboxes dependent on cbxPCVCatagory) after selection of value in PCVCatagory combobox.
    Last edited by June7; 08-07-2011 at 04:52 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You could try:

    Code:
    SELECT Catagories.Options
    FROM Catagories 
    WHERE Catagories.CatNo="1" And Catagories.PCVCatagory = FORMS![Classifier Synnex].[PCVCatagory];
    (Note the period)

    (or maybe FORMS![Classifier Synnex]![PCVCatagory])

    If you were trying to create a query in the query design dialog, you would need to fully qualify the reference to the control "[PCVCatagory]".

  8. #8
    gully300 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2011
    Posts
    4
    thanks for the help i have done it through a form as sudjested and it works great.

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

Similar Threads

  1. Cannot always overtype item from lookup list
    By sephiroth2906 in forum Forms
    Replies: 4
    Last Post: 05-16-2011, 09:13 AM
  2. Don't show lookup list options in report
    By dara in forum Reports
    Replies: 1
    Last Post: 02-17-2010, 10:26 PM
  3. Replies: 2
    Last Post: 01-25-2010, 09:23 AM
  4. Invisible LookUp Data List
    By aaghd in forum Access
    Replies: 3
    Last Post: 07-28-2009, 02:35 PM
  5. Lookup or list field: how Do I not show all records
    By scott munkirs in forum Forms
    Replies: 4
    Last Post: 04-13-2006, 12:44 PM

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