Results 1 to 6 of 6
  1. #1
    Bluebeard666 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2016
    Posts
    2

    Validation rules for Date()

    I'm terribly sorry if a similar question has been asked before, but I have been unable to find it.



    On my form I have a "date" field that automatically populates using Date() and I have a "Save" button that stores the form data and jumps to the next record.
    Upon creation of the new record, the Date field gets automatically populated again. However, the next day, the field will have the wrong date (date of the day before).

    So I am looking for a way to only have the "Date" populated out once another filled.

    At the same token, the users needs to be able to change the date manually, so I can't do it using a macro/VBA in the background.

    I hope someone has a suggestion how to approach this problem.

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Is the field bound,
    what does "automatically" mean,
    is it used for updating records as well as for inserting

  3. #3
    Bluebeard666 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2016
    Posts
    2
    I'm not sure what is being meant with "bound".
    What I did is create a table in the design view, created a column with the name "Training_date" and the Default value "Date()".
    Then I created a form that lets users input data. Due to the function "Date()", the field "Training_date" is automatically filled with the current date. The form has a "Save" button, that executes a "SaveRecord" command and starts a new record. Unfortunately, that means that it directly fills the field for the "Training_date".

  4. #4
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Bound means that the field on the form has a "Control Source" linked to the field on the table. If the Control Source is blank then it is an unbound object. It sounds as if it is bound.

    The user can change the date on the form and it will store that date in the Training_date field instead of the default value. All of this sounds just like you want it to happen.

    Seeing the date of the day before - is that not because you are seeing a record that was added the day before? If you go to a new record, will it not be showing today's date? When you open a form that is bound to a table it will always show the first record in the table unless you tell it to do something different.

    I am not sure why you have the save button as Access automatically saves a record once you move off it. Feel free to post a copy of your database it you wish.

  5. #5
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    What I did is create a table in the design view, created a column with the name "Training_date" and the Default value "Date()".
    If the table's default value is Date() and I'm adding a record today, I'm probably happy with the date I see so I'll leave it alone. If I look at that record tomorrow, it will be a different date because there is a function in the field, not a value. Perhaps that is what is happening.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by Bluebeard666 View Post

    ...I can't do it using a macro/VBA in the background...
    If you have the Default Value set to Date()...and the date is changing, from day to day, you already are using 'a macro/VBA in the background' to change the date!

    Having the Default Value set to Date() means that the current date is inserted when you create a New Record...it won't change on its own...but it is editable...i.e. the user can later change the date, if necessary.

    Linq ;0)>

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

Similar Threads

  1. Validation Rules
    By hinkwale in forum Access
    Replies: 2
    Last Post: 01-21-2015, 07:06 PM
  2. Validation Rules Help
    By Troop in forum Access
    Replies: 11
    Last Post: 03-05-2013, 01:26 PM
  3. Validation Rules in the Forms
    By JoeyHenry in forum Access
    Replies: 1
    Last Post: 02-04-2013, 05:07 PM
  4. Field rules/validation rules
    By sk88 in forum Access
    Replies: 14
    Last Post: 02-26-2012, 01:03 PM
  5. Validation Rules
    By esglover in forum Database Design
    Replies: 1
    Last Post: 07-23-2010, 08:02 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