Results 1 to 4 of 4
  1. #1
    caniread is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2015
    Posts
    86

    Lookup field name

    I have 5 fields that I need to look at in a query. The query will only have one row. Only one of the 5 fields will have a number in it. I need to write code that will look at these five fields and find the one with a number in it and return the field name in an unbound box in a form. I am not sure how to go about writing this code, can someone point me in the right direction?



    Thank you for the help,

    Isaac

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Will the other fields have data? Do you need to find a specific number or just if it has any number?

    I suspect the data structure is not normalized. What is this data for?
    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
    caniread is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2015
    Posts
    86
    There are more than five fields in the query but I only need to look at the five fields and only one of the fields will have a number. That is the field name I need to return on the unbound box. I already have it filtered down to a single row to look at every time it runs the code. Hopefully that makes sense.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Not quite an answer to my questions. So any number? Will other fields have any data? The field will contain only number, no alpha?

    You don't really need the field name, you need the data. Consider:

    Nz([Field1], Nz([Field2], Nz([Field3], Nz([Field4], [Field5]))))

    or

    Choose(IsNumeric([Field1]),[Field1], IsNumeric([Field2]),[Field2], IsNumeric([Field3]),[Field3], IsNumeric([Field4]),[Field4], IsNumeric([Field5]),[Field5])


    If the five fields are mutually exclusive - only 1 can have data - this is not a normalized structure.
    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.

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

Similar Threads

  1. Replies: 11
    Last Post: 06-15-2016, 06:20 PM
  2. Replies: 4
    Last Post: 03-17-2016, 07:16 AM
  3. Lookup values not appearing in Lookup field?
    By dominover in forum Access
    Replies: 4
    Last Post: 03-05-2016, 05:01 PM
  4. Replies: 8
    Last Post: 01-06-2016, 02:52 PM
  5. Replies: 3
    Last Post: 05-31-2014, 11:37 AM

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