Calculating a default date on an input form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dpmcdoug
    New Member
    • Aug 2006
    • 2

    Calculating a default date on an input form

    I am a relative novice with Access and I am developing an input form that I need a default date to populate, regardless of the input date e.g. If I input data on Tuesday, Sept 27, I want the default date to be the previous Saturday, Sept 23 or if I enter data on Friday, Sept 29, the default date should also be Saturday, Sept 23. Is there a way to do this with date math, since the input date could be any date from the 23rd through the 29th. This needs to happen for any date entered, to find the previous Saturday. Is this even possible?
  • PEB
    Recognized Expert Top Contributor
    • Aug 2006
    • 1418

    #2
    You need your default date to be based on the last Saturday?

    It is possible by writing code in VB in your on load Form property event!

    Do you want to continue with the code?

    Comment

    • dpmcdoug
      New Member
      • Aug 2006
      • 2

      #3
      Originally posted by PEB
      You need your default date to be based on the last Saturday?

      It is possible by writing code in VB in your on load Form property event!

      Do you want to continue with the code?
      I've been experimenting using VBA, which I'm finding has many more options then point and click, obviously! I'm just not sure of the logic necessary to make it look back to the previous Saturday, regardless of what day it is, unless of course, the day the record is entered is a Saturday.

      Any help pointing me in the right direction to accomplish this would be greatly appreciated!

      David

      Comment

      • PEB
        Recognized Expert Top Contributor
        • Aug 2006
        • 1418

        #4
        So my frien,

        See this expression:

        CVDATE("29/09/2006")-(DatePart("w", CVDATE("29/09/2006"),vbSaturd ay)-1)

        it returns the last saturday!

        So instaed 29/09/2006 you need to place your date!

        :)

        Comment

        Working...