Results 1 to 6 of 6
  1. #1
    Gilgamesh is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2012
    Posts
    5

    Dlookup issue

    Hi:

    Im trying to use the dlookup function in order to automatically populate the email box as soon as the client ID is selected, unfortunately, I dont know what kind of criteria should be used because it keeps giving me the email of the first record only. I already search thru google and youtube but i wasnt able to find the right answer.

    Hope you can help me. See enclosed DB for better understanding.

    Thank you in advance.



    Final.accdb

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Can't look at the sample right now, but does this fit?

    http://www.baldyweb.com/Autofill.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    If you omit a Criteria in your DLookup Function, as you've done, Access only returns a random value, usually the value from the first Record in the Table, as it is doing for you, here. If you want to use DLookup, change your ID_de_cliente_AfterUpdate event to this:

    Code:
    Private Sub ID_de_cliente_AfterUpdate()
     Me.Correo = DLookup("[Correo electronico]", "[Listado de clientes]", "[ID de cliente] = " & Me.[ID de cliente])
    End Sub

    and it will work as you want it to.

    And a word to the wise, in the future do not use Spaces in the names of Objects/Fields/Controls. Doing so requires extra work, which is often not done, and can lead to problems down the road. Better to use something like Listado_de_clientes or ListadoDeClientes.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    So you recommend making a second trip to the data with a DLookup() rather than getting the value from the combo, which has already made one?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Gilgamesh is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2012
    Posts
    5
    Thank you so much for the prompt and assertive response!. Just one last question, is there any book you can recommend in order to learn all of these procedures and rules?

    Pbaldy: Another person gave me your solution and I find it better, though I dont understand how to perform it. I'll work on it. Thank you.

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by pbaldy View Post

    ...So you recommend making a second trip to the data...
    Not really, but

    1. The OP doesn't have the needed data as part of the Combobox RowSource
    2. The OP requested help using DLookup to accomplish his task
    3. I suspected that the below statement, from the OP, would be true


    Quote Originally Posted by Gilgamesh View Post

    ...though I don't understand how to perform it...
    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. DLOOKUP issue
    By gemadan96 in forum Forms
    Replies: 7
    Last Post: 11-01-2012, 06:21 PM
  2. Dlookup issue
    By brharrii in forum Programming
    Replies: 3
    Last Post: 06-22-2012, 07:08 PM
  3. Dlookup annoying issue
    By Lupson2011 in forum Forms
    Replies: 8
    Last Post: 02-14-2012, 08:28 AM
  4. DLookup issue
    By seth1685 in forum Programming
    Replies: 5
    Last Post: 01-12-2012, 08:55 AM
  5. Easy DLookup Issue
    By Niki in forum Access
    Replies: 7
    Last Post: 05-25-2011, 03:00 PM

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