Access: Change the date with the plus and minus key
In Microsoft Office Access, you can change the date using the plus and minus keys. We show you how it works.
Change the date in Access at the push of a button
With a simple listing you can get the database Access to increment the date by one day each time the key [+] is pressed in a date field of a form instead of a date: The key [-] sets the date by one day back.
Erwin Schulz
- To do this, load the form you want to extend with this functionality into the design view.
- Mark the field with the date and after a click with the right mouse button select the item "Properties".
- In the "Event" tab, select the bottom entry "On key" and then click the button with the three dots to open the "Code editor".
- Enter the listing on the screenshot here. If your field name is not "Date", you have to adapt the macro accordingly.
- However, because the event procedure only works if a value is entered in the date field, you should also assign this field a default value. To do this, switch to the "Data" tab and, for example, enter the string "Date ()" in the "Default value" field if you want to enter the current date as a starting point in the date field.
- Then switch to the form view. You can now try out your new date function there. By making minor changes and extensions to the listing, you can also ensure that, for example, the [+] key increases the date by 10 days or the [w] key (ASCII code 119) increases the date by one week (7 days).