Results 1 to 5 of 5
  1. #1
    Perfac's Avatar
    Perfac is offline Expert
    Windows 7 64bit Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618

    Expression Between dates

    I'm embarrassed to be back with something similar that took more than 50 post. A reminder the expression below works well.



    VatRate03: DLookUp("[VatRate01]","t02VatRate","VatCode01='" & [VatCodePurchases01] & "' And #" & Format([DocumentDate01],"yyyy-mm-dd") & "# Between [StartDate11] And [EndDate13]")

    Don't know why I battle to find the next one without an error. I am trying;
    Wek_Id03: Dlookup(" [WekID] ","q01Week",#" & Format([PubHolidayDate01]), "yyyy-mm-dd") & "# Between [StartDate13] And [EndDate10]")
    Click image for larger version. 

Name:	Hold01.png 
Views:	14 
Size:	83.0 KB 
ID:	33785
    Throughout my application I am trying to spare every possible entry or click of the mouse that a user don't need to make. In this example; PubHolidayDate01 is entered in q01publicholidays and I need the expression in green to return the WekID where PubHolidayDate01 falls between StartDate13 and Enddate10 from q01 week. The error. "The expression you entered has an invalid date value.
    Attached Thumbnails Attached Thumbnails Holidays2017.png  

  2. #2
    Perfac's Avatar
    Perfac is offline Expert
    Windows 7 64bit Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    Ignore the image in blue.

  3. #3
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    You're having problems because you are making the same syntax errors as before:
    This SHOULD work:
    Code:
    Wek_Id03: Dlookup("WekID","q01Week","PubHolidayDate01 Between #" & Format(StartDate13,"mm/dd/yyyy") & "# And  #" & Format(EndDate10,"mm/dd/yyyy") & "#")
    OR if preferred
    Code:
    Wek_Id03: Dlookup("WekID","q01Week","PubHolidayDate01 Between #" & Format(StartDate13,"yyyy-mm-dd") & "# And  #" & Format(EndDate10,"yyyy-mm-dd") & "#")
    However, as I suggested the same syntax last time, I won't be surprised when you say it doesn't!!!

    NOTE:
    1. your fields have no spaces so I've removed unnecessary square brackets
    2. I've removed the space either side of WekID
    3. The Date formatting needs to be on the StartDate & EndDate as shown

    P.S. I ignored both images
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  4. #4
    Perfac's Avatar
    Perfac is offline Expert
    Windows 7 64bit Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    Most of the time when I copy expressions from here into my system it works. This one leaves a blank, no error message. My Windows system and date format of choice is Short date dd-MMM-yyyy, including table t01week and t01Publicholidays. The previous big issue with that expression was not the format of the date since yyyy-mm-dd is working right now on the other one. I recreated t01week and the date formats, no luck yet.

  5. #5
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Suggest you upload sample data for someone to test it.
    The syntax you ended up with from your previous thread is non standard and I believe it will not work for all dates.
    By contrast, the syntax I provided is the accepted syntax which should therefore work.
    It doesn't matter what your default date format is n Windows or Access as dates are actually stored as double number datatype.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

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

Similar Threads

  1. Replies: 2
    Last Post: 09-19-2017, 11:31 AM
  2. Replies: 2
    Last Post: 01-29-2017, 07:50 AM
  3. Replies: 3
    Last Post: 04-03-2013, 05:53 PM
  4. Replies: 3
    Last Post: 02-04-2013, 03:45 PM
  5. Replies: 16
    Last Post: 03-01-2012, 08:21 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