Results 1 to 4 of 4
  1. #1
    Ctrl-v is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    17

    dlookup function dependent on combo box only pulling the first row regardless of selection

    Hi,



    Very new with Access. I am trying to create a few dlookups, but I can't seem to get things right. The best I could do is get the information from the first row even when the criteria does not match that row.

    This is the code that is associated with the combo box:

    Option Compare Database
    Option Explicit


    Private Sub ClientINTI_AfterUpdate()
    RelaTWO = DLookup("RelationshipTwo", "ClientInfo", "ClientINTI= '" & ClientINT & "'")
    NameTWO = DLookup("FullNameTwo", "ClientInfo", "ClientINTI= '" & ClientINT & "'")
    End Sub

    I attached the database.

    Wrote in some more explanation on the form in the database.

    A great thanks to anyone that can help!!
    Attached Files Attached Files

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    There were several errors.
    The combo is bound to the hidden ID field so that needs to be used in the DLookup expressions
    ID is a number field so use of text delimiters is incorrect

    Also your field is called ClientInt not ClientInti
    Attached Files Attached Files
    • File Type: zip S.zip (40.0 KB, 3 views)
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    Ctrl-v is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    17
    Hey,

    Thank you for that fix!

    Can you explain the "
    The combo is bound to the hidden ID field so that needs to be used in the DLookup expressions"?

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    All combo boxes are bound to one of the fields.
    This gives a value that can be used elsewhere e.g. In a DLookup
    Normally this is the first field or Column(0).
    As it is usually an ID field it normally hidden.

    Hth
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

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

Similar Threads

  1. checkbox dependent IIf function
    By jadira in forum Access
    Replies: 8
    Last Post: 10-06-2016, 09:27 AM
  2. Replies: 1
    Last Post: 09-25-2015, 09:05 AM
  3. Replies: 4
    Last Post: 06-01-2014, 09:09 PM
  4. Replies: 3
    Last Post: 05-12-2012, 10:54 AM
  5. Replies: 3
    Last Post: 02-26-2009, 10:17 AM

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