Results 1 to 5 of 5

Thread: 21 days

  1. #1
    Join Date
    Jan 2014
    Posts
    3

    Unanswered: 21 days

    Having a issue trying to fig out how to keep people from saving data before/after they're allowed. When they receive their date of departure they are only allowed to start there form 21 days before that date. What I need to know would it be in a macro or do I need to come up w a sql command to that. Also I need it to not allow them to do it after they leave which is happening. So basically what I need is a simple can't save your data unless your in that 21 day window. I'm thinking a macro between statement but this is a first for me. Thank you in advance hopefully I explained that right

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    If it were me I'd probably implement this using a trigger or stored procedure (assumign you are using A2010 on and using ACCDB/ACCDE not MDB/MDE or ADP)

    http://stackoverflow.com/questions/3...e-in-ms-access

    A less effective solution would be to put the constraint into the form design, but that still means that users can modify values either through a datasheet, other form(s) or direct entry into the table.
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    If it were me I'd probably implement this using a trigger or stored procedure (assumign you are using A2010 on and using ACCDB/ACCDE not MDB/MDE or ADP)

    How do I make a stored procedure in MS Access? - Stack Overflow

    A less effective solution would be to put the constraint into the form design, but that still means that users can modify values either through a datasheet, other form(s) or direct entry into the table.
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    495
    Provided Answers: 24

    no macro

    If it is a form, disable the button until the date gets to 21.
    put a text box on the form that reads the start date.
    and a text box that calcs the days.
    set the property: txtElapsedDate.controlsource = DateDiff("d",Date,txtStartDate)

    when the txtElsapedDate >= 21, the button enables for them to make changes.

  5. #5
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Quote Originally Posted by ranman256 View Post
    when the txtElsapedDate >= 21, the button enables for them to make changes.
    That cannot work:

    1. The question was to be able to save the data when the current date is withing a 21 day time frame:
    Quote Originally Posted by Higgs84 View Post
    So basically what I need is a simple can't save your data unless your in that 21 day window.
    NOT when 21 or more days elapsed.

    2. There are other (built-in) means than a button to save data from a form that the proposed solution does not prevent from using.

    Personally, if the only mean to access the data is through a form: no possibility to run an UPDATE query and no possibility to open the table (i.e. use of an MDE-ACCDE), I would set up an event handler for the BeforeUpdate event of the Form, test the date window here and set the cancel argument to True when the test fails.

    In any other case, Healdem's solution remains the only one, although a don't specially like using the so-called "triggers" in Access.
    Have a nice day!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •