Results 1 to 8 of 8
  1. #1
    guitarsweety is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2019
    Posts
    5

    Question DLookup in report

    I have a report named Bonus Attendance Report with an unbound textbox named txtprorate and a bound field named AdjServiceDate.

    The table name is BonusAmount with fields named Payment and ProDte.



    I'm trying to search the table in the ProDte and find a match with the AdjServiceDate that will then list the Payment in the unbound textbox on the report.

    I would also like to have a default amount of $1000.00 if no match is found. Is this possible?





    Code:
    =DLookUp("Payment","BonusAmount","ProDte = '" & [Reports]![Bonus Attendance Report]![AdjServiceDate] & "'")

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Use Nz()

    =Nz(DLookUp("Payment","BonusAmount","ProDte = '" & [Reports]![Bonus Attendance Report]![AdjServiceDate] & "'"), 1000)
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    guitarsweety is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2019
    Posts
    5
    Thank you June7. I tried that and got a #Error

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Expression works for me.

    DLookup returns Null when there is no match. Did it work before?

    What field type is ProDte? If it is a DateTime, use # instead of apostrophe delimiter.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    guitarsweety is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2019
    Posts
    5
    I tried that but got the same error. I'm not really sure of the correct placement of the #

    The ProDte and the AdjServiceDate are date fields. The Bonus amount is currency.

    Code:
    =Nz(DLookUp("Payment","BonusAmount","ProDte = #" & [Reports]![Bonus Attendance Report]![AdjServiceDate] & "'"),1000)
    Last edited by guitarsweety; 10-21-2021 at 01:04 PM. Reason: Added additional info

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Have to replace both apostrophes.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    guitarsweety is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2019
    Posts
    5
    I'm not sure which one to replace. It says invalid date

    Code:
    =Nz(DLookUp("Payment","BonusAmount",ProDte = #'' & [Reports]![Bonus Attendance Report]![AdjServiceDate] & "),1000)
    Last edited by guitarsweety; 10-21-2021 at 01:56 PM. Reason: Error

  8. #8
    guitarsweety is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2019
    Posts
    5
    I figured it out! Thank you so much for your help!
    Code:
    =Nz(DLookUp("Payment","BonusAmount","ProDte = #" & [Reports]![Bonus Attendance Report]![AdjServiceDate] & "#"),1000)

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

Similar Threads

  1. DLookup Stock Levels On A Report
    By DMT Dave in forum Access
    Replies: 6
    Last Post: 07-27-2020, 04:48 AM
  2. Replies: 3
    Last Post: 04-08-2020, 10:39 AM
  3. DLookUp Function in Report Footer
    By craigger01 in forum Reports
    Replies: 12
    Last Post: 09-28-2018, 12:11 PM
  4. Dlookup in Report
    By Erictsang in forum Reports
    Replies: 10
    Last Post: 10-30-2017, 03:12 AM
  5. DLookup In Report only showing on first line
    By crimedog in forum Reports
    Replies: 11
    Last Post: 04-09-2015, 07:55 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
  •  
Other Forums: Microsoft Office Forums