Results 1 to 4 of 4
  1. #1
    epardo87 is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Dec 2016
    Posts
    101

    Dlook up not working with combobox data

    Hello All,



    I have this form with a combobox and a text field, the text field should lookup a value in a table depending on which selection was made in the combobox. now I have the following formula in the textbox control source:

    =DLookUp("[Supervisor]","[tbl-1-0-Areas]","[Area]='" & [Forms]![frm20MainStatus]![cmbArea] & "'")

    I have experimented before and this is what happens:
    1. if I write the values on the combobox using the wizard (I mean, not linked to any table) then the text box finds and shows the required information.
    2. if I link the combobox to show the values in a table, then the textbox doesn't show anything...


    actually, that combobox should filter a query as well, and it happens the same with the query, doesn't work if combobox is pulled from table and works if cambobox values are entered manually...

    can anybody tell me why is this happening?

  2. #2
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,463
    I would put that dlookup code in the AfterUpdate event of the combo box and see if it works (take it out of that control Source).

    me.textbox = DLookUp("[Supervisor]","[tbl-1-0-Areas]","[Area]='" & [Forms]![frm20MainStatus]![cmbArea] & "'")

    What is a value of Area and what is the datatype?

  3. #3
    epardo87 is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Dec 2016
    Posts
    101
    Quote Originally Posted by Bulzie View Post
    I would put that dlookup code in the AfterUpdate event of the combo box and see if it works (take it out of that control Source).

    me.textbox = DLookUp("[Supervisor]","[tbl-1-0-Areas]","[Area]='" & [Forms]![frm20MainStatus]![cmbArea] & "'")

    What is a value of Area and what is the datatype?
    Thanks for your answer,

    I just tried it but had no success, what I did is to make a query of that table and link the combobox to the query, everything works fine now, I just wonder why it doesn't when linked directly to the table.

    the column "area" is a short text and the values are "group A" or "Group B"

  4. #4
    epardo87 is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Dec 2016
    Posts
    101
    at the end this worked for me:
    Code:
    Private Sub btnStation_Click()
        Dim AreaLookUp As String
          AreaLookUp = DLookup("Area", "Qry-xreference", "StationDescription='" & Forms!frm30UserData!lstStation & "'")
        [Forms]![frm20MainStatus]![cmbArea] = AreaLookUp

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

Similar Threads

  1. combobox not working
    By LucLc in forum Access
    Replies: 4
    Last Post: 05-25-2016, 12:08 PM
  2. Combobox Query not working
    By ntaylor95814 in forum Forms
    Replies: 0
    Last Post: 04-15-2014, 04:29 PM
  3. DLook up VB in a Sub Form
    By smc678 in forum Programming
    Replies: 3
    Last Post: 12-23-2013, 01:26 PM
  4. dlook up and setfocus
    By msasan1367 in forum Access
    Replies: 3
    Last Post: 07-15-2013, 12:03 PM
  5. Dlook Up
    By cap.zadi in forum Forms
    Replies: 4
    Last Post: 12-26-2011, 12:20 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