Results 1 to 3 of 3
  1. #1
    Gilmer is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2019
    Posts
    1

    How to stop Access to switch day with month when month is invalid and day is valid

    I have a date field named dateffectivedate (mm/dd/yyyy). In the input I want to check that mm is between 1 and 12 otherwise give an error message. I can use datePart or Month() to extract the month of the date. My problem is that a user enters a date as 15/2/2019 where 15 is the month typed by mistake Access automatically changes the date to 2/15/2019. So when it reaches the IF statement month is correct because it was changed to 2 but that is not the month I wanted. How can I stop this switch. Is there a setting in access to stop doing this?Thanks for your help.

  2. #2
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    One way to do what you want is to have the Date Entry field be a Text field. Then you can check/validate it, and assign it to a Date field.
    Or, use a Date Picker instead of letting them free-form the date entry (Google "Access Data Picker control").

  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
    See if this helps http://allenbrowne.com/ser-36.html

    Otherwise, one way to deal with this is UNBOUND textbox (and/or separate UNBOUND boxes for each date part). Then code validates and saves to record, if saving to record is necessary.
    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.

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

Similar Threads

  1. Last Month Data Using Month Field, Access 2013
    By Biplab1985 in forum Queries
    Replies: 4
    Last Post: 02-27-2017, 06:26 AM
  2. Replies: 2
    Last Post: 06-14-2016, 02:36 PM
  3. Replies: 3
    Last Post: 12-29-2014, 10:14 AM
  4. Replies: 5
    Last Post: 10-08-2014, 02:23 PM
  5. Replies: 6
    Last Post: 05-05-2014, 10:51 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