Results 1 to 7 of 7
  1. #1
    mdex is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    11

    Dlookup syntax and requery help

    I have a form (Checks) for auditing passwords. 2 comboboxes on that form, TeamNamecbo and AccountTypecbo referenced from Accounts Table. Within the accounts form I also have a field called PasswordRequirements.



    On the Checks form I want an unbound txt box that looks up the PasswordRequirements from accounts when TeamNamecbo and AccountTypecbo are entered.

    I have composed the below dlookup which when placed in the txt boxes control source returns the very first PasswordRequirements entry it finds from Accounts table as soon as the form is loaded and combo boxes are blank.

    =DLookup("PasswordRequirements", "Accounts", "[TeamName]=" & Forms!checks!TeamNamecbo And "[AccountType]=" & Forms!checks!AccountTypecbo)

    Can I place some kind of requery on the combo boxes or place the lookup somewhere else so it updates correctly dependant on the data from the combo boxes?

  2. #2
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    Simply bring the PasswordRequirements field into the data for the combo as an extra hidden column.

    In the after update event of the second combo use something like
    Code:
    Me.YourTextBox = Me.AccountTypecbo .Column(1)

    Bear in mind that the column numbering on combo's starts at 0
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    mdex is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    11
    Excellent.

    Much simpler than the method I was trying to use.

    Thanks

  4. #4
    LLJ is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2018
    Posts
    15
    Your solution for mdex worked perfectly for me, too - After Update event on Me.BookTitlecbo correctly displays value of Me.BookTitlecbo.Column(2) in Me.Publisher. However, the value is not getting stored in the underlying table. What do I need to do next?

  5. #5
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    I'm not sure you should be storing a value if you can already look it up ?

    Generally speaking if you already have that data stored you shouldn't store it again, unless there is some date based change that might mean that data could change in the future and you had to record the old value as at a specific time. Storing it in two places means if it's wrong or needs editing you have to try and remember to make those changes everywhere.

    If your Publisher control is unbound then it wouldn't save as it's not connected to your recordset.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  6. #6
    LLJ is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2018
    Posts
    15
    You're right, of course, about not storing the data twice. But let me be a little more thorough about what I'm trying to do... in a few hours. Should I continue to reply to this solved thread, or start a new one?

  7. #7
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    Start fresh. It will avoid confusion.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

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

Similar Threads

  1. DLookup Syntax
    By sanderson in forum Forms
    Replies: 11
    Last Post: 09-23-2015, 02:38 PM
  2. DLookup syntax
    By kattatonic1 in forum Forms
    Replies: 3
    Last Post: 07-23-2014, 07:53 AM
  3. Requery input parameters syntax?
    By hinsdale1 in forum Forms
    Replies: 15
    Last Post: 05-01-2013, 11:56 PM
  4. IIf and dlookup syntax
    By AndycompanyZ in forum Forms
    Replies: 3
    Last Post: 06-28-2011, 02:47 PM
  5. dlookup() syntax
    By markjkubicki in forum Programming
    Replies: 4
    Last Post: 08-24-2010, 12:31 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