Results 1 to 3 of 3
  1. #1
    apk19 is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    May 2015
    Posts
    30

    DLookup shows primary key and not corresponding value in lookup table

    I have a subform with a few unbound text boxes using DLookup to find values in a query. All of the textboxes (and DLookup functions) work except one and I think I know why but don't know how to solve it.

    The function in question looks up a value in a table that uses a lookup function into another table, which has only two columns: the PK and the value. The DLookup sees this and returns the PK when I actually want it to return its value.



    I know this is breaking Law 2, but there are 109 different values in that table and those values are used either once or twice for every record.

    The problem is that I don't know what to change to fix this: The table/field that uses the lookup (trying to bind the value), the query (looking up the value in the lookup table), or the DLookup function itself. I've tried tinkering with them all to no avail.

  2. #2
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    If you MUST persist with the lookup field, my suggestion would be to either
    - query the query that uses the PK to return the value (add the second table to this query)
    - or create a custom function that uses the ID returned by DLookup. The function would construct a sql statement and assign it to the control.
    Just guessing - I've always avoided lookup fields like the plague.

  3. #3
    apk19 is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    May 2015
    Posts
    30
    Hi Micron,

    Yes, unfortunately it was a necessity...but thank you for the suggestions! I managed to get it up and running using a subquery and using DLookup directly onto that query.

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

Similar Threads

  1. DLookup text box on form shows error
    By Abacus1234 in forum Forms
    Replies: 8
    Last Post: 04-28-2015, 03:01 PM
  2. Converting lookup text field to number for primary
    By Ruegen in forum Database Design
    Replies: 4
    Last Post: 09-11-2013, 08:23 PM
  3. Lookup field shows ID # and not text
    By kelkan in forum Forms
    Replies: 3
    Last Post: 01-26-2013, 09:19 PM
  4. Replies: 8
    Last Post: 03-22-2012, 08:48 AM
  5. Replies: 5
    Last Post: 12-21-2011, 07:16 PM

Tags for this Thread

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