Results 1 to 6 of 6
  1. #1
    Shamli is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Jul 2018
    Location
    California
    Posts
    142

    Prevent Users from Entering date from 2 Previous week

    I need a help in preventing users from choosing the date 2 weeks from today.



    Employees have to log every Friday of the week,
    And if they wanted to edit any information they can access only 2 Fridays from the date they are trying to modify.

    I know how to prevent users from entering future dates but not this particular one.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    Code:
    VBadDate = DateAdd("d",14,Date())
    
    if txtDate =vBadDate then
       MsgBox "bad date"
    else
       'Do sstuff
    end if

  3. #3
    Shamli is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Jul 2018
    Location
    California
    Posts
    142
    Where do I have to place the code?
    I have the date as a date picker from the text box.Do I have to place in the on click function of the text box?
    Quote Originally Posted by ranman256 View Post
    Code:
    VBadDate = DateAdd("d",14,Date())
    
    if txtDate =vBadDate then
       MsgBox "bad date"
    else
       'Do sstuff
    end if

  4. #4
    Shamli is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Jul 2018
    Location
    California
    Posts
    142
    I tried using this code in the on click event in the textbox. Its not giving an error message instead it is letting me to choose the date


    Quote Originally Posted by ranman256 View Post
    Code:
    VBadDate = DateAdd("d",14,Date())
    
    if txtDate =vBadDate then
       MsgBox "bad date"
    else
       'Do sstuff
    end if

  5. #5
    Shamli is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Jul 2018
    Location
    California
    Posts
    142
    This Validation rule helps in preventing users entering date from previous week.
    What is the syntax from 2 previous weeks.
    I replaced 1 with 2 and its not letting me choose date from the previous week instead its letting me choose from the previous 2 week.


    Weekday([WeekendingCmbo])=6 And Year([WeekendingCmbo])*53+DatePart("ww",[WeekendingCmbo])=Year(Date())*53+DatePart("ww",Date())-1

  6. #6
    Shamli is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Jul 2018
    Location
    California
    Posts
    142
    Okay. So this one helped !

    Weekday([WeekendingCmbo])=6 And Between Date() And DateAdd("ww",-2,Date()) Or Between Date() And DateAdd("ww",+2,Date())

    So this help me in choosing the day as Friday. and within 2 previous week and 2 future week (Friday).




    Thank you!

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

Similar Threads

  1. Replies: 9
    Last Post: 06-19-2015, 03:37 PM
  2. Replies: 3
    Last Post: 01-21-2015, 02:40 PM
  3. Replies: 2
    Last Post: 12-01-2014, 02:53 AM
  4. Replies: 2
    Last Post: 08-05-2014, 07:06 AM
  5. Replies: 3
    Last Post: 09-19-2013, 10:18 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