Results 1 to 4 of 4

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

  1. #1
    Ctrl-v is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    7

    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
    ridders52's Avatar
    ridders52 is offline Voodoo Is Practised
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    2,397
    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, 1 views)
    Colin (Mendip Data Systems), Website, email
    If this has helped, please click the star button and leave a comment

  3. #3
    Ctrl-v is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    7
    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
    ridders52's Avatar
    ridders52 is offline Voodoo Is Practised
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    2,397
    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 (Mendip Data Systems), Website, email
    If this has helped, please click the star button and leave a comment

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, 08:27 AM
  2. Replies: 1
    Last Post: 09-25-2015, 08:05 AM
  3. Replies: 4
    Last Post: 06-01-2014, 08:09 PM
  4. Replies: 3
    Last Post: 05-12-2012, 09:54 AM
  5. Replies: 3
    Last Post: 02-26-2009, 09: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
  •  
Tech Forums: Microsoft Office Forums