Results 1 to 4 of 4
  1. #1
    AussieGal is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    56

    Message box to cofirm entry if date outside range

    I have a date field 'servicedate' on a form. I want to put a condition on it to reduce data entry problems. Generally when a record is entered this field would be completed with a date on or about 20 days before the current date. I want a message box to appear if a date is out of this range. eg older than 30 days or if the date is in the future. It would say 'Are you sure that you want this date, it is outside the normal range' and they could click yes, no or cancel. I don't want it so users can't enter dates outside this range, I just want them to have to confirm that the date they entered is outside the 'normal range'. I have trouble with VB but am slowly trying to learn, I believe I would be entering vb in the after update field?. I have looked around for nearly a day and can't find any code that has worked or that I have understood enough to adjust to make it work for my situation. Any help would be appreciated.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    For validation you can either use the before update event of the form or the before update event of the textbox. I lean towards the form:

    http://www.baldyweb.com/BeforeUpdate.htm

    In your case:

    If Me.servicedate < Date() - 20 OR Me.servicedate > Date() Then
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    AussieGal is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    56
    WOuld this provide a message box only if the date was outside my range? I want a box to appear only if the date is outside my range, and I want them to have an option to put in any date, but just to be aware that it is in not in the normal range... eg they might have put in 6/6/11 instead of 6/6/12, or the wrong month etc. Although sometimes we need to enter dates a few months back, so I want that option, but to have a warning pop up so it is a not a data entry error. Does that make sence?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Did you try it? You can just use the message box if you want, or you can use a Yes/No message box and ask the user if they want to keep the date or not.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Message Box Based on Date Range
    By MSAccessOldTimer in forum Programming
    Replies: 4
    Last Post: 05-14-2012, 04:25 PM
  2. Date Range with Error Message Box
    By Huddle in forum Access
    Replies: 4
    Last Post: 05-11-2012, 01:33 PM
  3. Change error message for dupicate entry
    By Amber in forum Forms
    Replies: 3
    Last Post: 03-12-2012, 02:39 PM
  4. Date Range Report with Multiple Date Fields
    By StevenCV in forum Reports
    Replies: 13
    Last Post: 02-29-2012, 08:29 AM
  5. Error Message re: data entry of date
    By Pro-not in forum Access
    Replies: 9
    Last Post: 10-22-2010, 10:14 AM

Tags for this Thread

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