Results 1 to 7 of 7

DLOOKUP #Error

  1. #1
    neo651 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2011
    Posts
    107

    DLOOKUP #Error

    I have a Form called frmMain with a number of controls who's Control Source is a DLOOKUP() expression. The values are looked up from a couple of different queries. Within frmMain there is an unbound combo box (cboWeekOf) where the user can select a date. This selection is used as a criteria for those queries. The DLOOKUP expressions all work perfectly fine until I close and reopen the database, at which point they all display "#Error". I found that if I change the name of cboWeekOf, close frmMain, reopen frmmain, rename cboWeekOf to its original name, then close and reopen frmMain again everything works fine. But I have to do this everytime I open the database file.

    Has anyone ever encountered this?

    Thank you.

  2. #2
    ssanfu is offline VIP
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    3,466
    "cboWeekOf" is NULL when the form opens, so the DLookup function returns an error.
    Try setting the default value of the combo box "cboWeekOf" to DATE().

    Close, then reopen the database.

    There are other ways to populate the controls instead of setting the control source to a DLOOKUP.
    One way sould be: in the after update event of the combo box "cboWeekOf", you could have code that pushes the value from the DLookUp function into the respective controls. The DLookup would only be executed when the combo box "cboWeekOf" is changed.
    HTH
    -----
    Steve
    --------------------------------
    "Veni, Vidi, Velcro"
    (I came; I saw; I stuck around.)

  3. #3
    neo651 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2011
    Posts
    107
    I do have a default value set for cboWeekOf, it's set to an expression that returns the date of the Monday of the current week.

  4. #4
    ssanfu is offline VIP
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    3,466
    I have never heard of that happening before. Would you post the DLOOKUP expression?
    HTH
    -----
    Steve
    --------------------------------
    "Veni, Vidi, Velcro"
    (I came; I saw; I stuck around.)

  5. #5
    neo651 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2011
    Posts
    107
    =DLookUp("Stats_To_Date_2012","qryData","[Office]=1 AND [Panel]=13")

    This is one of them, they're all identical syntax with "Stats_To_Date_2012", "1" and "13" swapped out for different values depending on what's being looked up. It's not a complex expression.

  6. #6
    ssanfu is offline VIP
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    3,466
    Now I'm more confused. How are the DLOOKUP()s connedted to the combo box "cboWeekOf"?
    Is "cboWeekOf" a parameter for "qryData"?

    Are all of the domains for the DLOOKUPs the same ("qryData")?

    You might read this post. See post #10 by Rod.
    http://www.accessforums.net/queries/...ror-30691.html
    HTH
    -----
    Steve
    --------------------------------
    "Veni, Vidi, Velcro"
    (I came; I saw; I stuck around.)

  7. #7
    neo651 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2011
    Posts
    107
    There are three different queries used as the domain for the different DLOOKUP expressions. All of those queries use the value of the combo box as a criteria.

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

Similar Threads

  1. DLookup Syntax Error
    By uncletreetrunk in forum Programming
    Replies: 4
    Last Post: 07-30-2012, 01:29 PM
  2. DLookup Error
    By uncletreetrunk in forum Programming
    Replies: 5
    Last Post: 07-16-2012, 07:33 PM
  3. Error in Dlookup?
    By cindytan in forum Forms
    Replies: 1
    Last Post: 02-07-2012, 12:40 AM
  4. Error using ELookup but not DLookup
    By Rawb in forum Programming
    Replies: 12
    Last Post: 10-18-2010, 06:09 AM
  5. DLookup error
    By jgelpi16 in forum Programming
    Replies: 3
    Last Post: 08-25-2010, 06:26 AM

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