Results 1 to 7 of 7
  1. #1
    BLFOSTER is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jun 2013
    Posts
    68

    Unhappy DLookup with DateSerial problem

    I am trying to use DLookup as the control source of a text box on a report. All I get is error. Can anyone help?



    =DLookUp("[AllottedTickets]","Allottments","[DateIn] between DateSerial(Year(Forms!MyForm![DispenseDate])),Month(Forms!MyForm![DispenseDate]-1,1) And DateSerial(Year(Forms!MyForm![DispenseDate])),Month(Forms!MyForm![DispenseDate]),0) and [Site] = Me.[Referring Branch]) ")

  2. #2
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    What is the error you are getting?

    Without that, maybe this will work:
    Code:
    = DLookup("[AllottedTickets]", "Allottments", "([DateIn] Between #" & DateSerial(Year(Forms!MyForm![DispenseDate]), Month(Forms!MyForm![DispenseDate]) - 1, 1) & "# And #" & DateSerial(Year(Forms!MyForm![DispenseDate]), Month(Forms!MyForm![DispenseDate]), 0) & "# and ([Site] = '" & Me.[Referring Branch] & "')")
    If not, please provide more information.

  3. #3
    BLFOSTER is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jun 2013
    Posts
    68
    It is prompting for "Me" when I open the report and the text box says #Type!

    Thank you so much for helping me!

  4. #4
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    Does that error refer to your code or mine? If yours, try the replacement code I gave you.

  5. #5
    BLFOSTER is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jun 2013
    Posts
    68
    Oh, I am sorry. Yours.

  6. #6
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    Can you verify [Referring Branch] is a Control Name on your form? If not, then change it to the actual Control Name that is mapped to the field [Referring Branch].

  7. #7
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    With something as long as this, I would be inclined to add it to the OnLoad or OnCurrent Event (whichever is appropriate in your case, or a different event) so it is clearly visible in code - easier to debug later if needed.

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

Similar Threads

  1. DateSerial and IIF Statements
    By mindbender in forum Queries
    Replies: 2
    Last Post: 06-19-2014, 05:57 AM
  2. DateAdd DateSerial
    By aellistechsupport in forum Queries
    Replies: 2
    Last Post: 04-30-2014, 05:09 PM
  3. Dateserial and datetime
    By webisti in forum Access
    Replies: 1
    Last Post: 06-17-2013, 11:31 AM
  4. Problem with a DateSerial Function
    By razkowski in forum Queries
    Replies: 1
    Last Post: 01-31-2013, 04:47 PM
  5. DateSerial Format
    By venu_resoju in forum Reports
    Replies: 4
    Last Post: 01-19-2013, 02:20 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