Results 1 to 8 of 8
  1. #1
    RB85 is offline Novice
    Windows 11 Access 2016
    Join Date
    May 2023
    Posts
    25

    Expression Builder Date Format


    Just been struggling for a while to update the Control Source using the Expression Builder for a text box on my form. I want it to look at a date range linked to a selected date in another textbox on the form. The two date formats appear to be different, the expression builder is looking for US format (mm/dd/yyyy) but the text box date format is my normal dd/mm/yyyy. Can I get the date format in the control source to look for dd/mm/yyyy?

  2. #2
    RB85 is offline Novice
    Windows 11 Access 2016
    Join Date
    May 2023
    Posts
    25
    This is my expression:
    =DMax("[qrySensorPressureCalcs]![Elevation (m H2O)]","[qrySensorPressureCalcs]","[qrySensorPressureCalcs]![RecordingDateTime]<=#" & [Date1] & "#")

    Trying to get it before [Date1], which is 12 August 2023, but when I put that date in [Date1] it looks for the max before 08/12/2023. I tried changing the format of Date1 to mm/dd/yyyy in its properties but its made no difference to the expression answer only displays in that format on the form.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Are you outside the U.S.? Is your system date in dd/mm/yyyy structure? Review http://allenbrowne.com/ser-36.html

    =DMax("[Elevation (m H2O)]", "[qrySensorPressureCalcs]", "[RecordingDateTime]<=#" & Format([Date1], "mm\/dd\/yyyy") & "#")
    Last edited by June7; 08-26-2023 at 09:22 PM.
    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.

  4. #4
    RB85 is offline Novice
    Windows 11 Access 2016
    Join Date
    May 2023
    Posts
    25
    Thanks for the response. I am outside US and system date is dd/mm/yyyy.

    I tried that expression and with some slight adjustments looking at that link you provided but I just get #Name? error now.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    I was missing a quote mark in my example. Are you sure you have correct syntax and field names? Is Date1 a field and/or textbox in form?
    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.

  6. #6
    RB85 is offline Novice
    Windows 11 Access 2016
    Join Date
    May 2023
    Posts
    25
    Yeah I noticed the missing quote but didnt work with it added. Date1 is a textbox in the form.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Sorry, remove Me. from the expression.
    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.

  8. #8
    RB85 is offline Novice
    Windows 11 Access 2016
    Join Date
    May 2023
    Posts
    25
    Yep that works, thanks a lot!

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

Similar Threads

  1. Replies: 11
    Last Post: 06-16-2022, 08:45 AM
  2. Replies: 2
    Last Post: 03-12-2018, 08:16 AM
  3. Date format and expression
    By cenibyte in forum Queries
    Replies: 8
    Last Post: 04-11-2016, 11:32 AM
  4. Replies: 1
    Last Post: 10-08-2015, 02:20 PM
  5. Using expression builder to find lowest date
    By MMcKenna in forum Queries
    Replies: 1
    Last Post: 03-20-2012, 02:28 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