Microsoft Office Online
Sign in to My Office Online (What's this?) | Sign in

 
 
Microsoft Office Access
Search
Search
 
Updates: (c) Microsoft
Office downloads
 
 
 
Warning: You are viewing this page with an unsupported Web browser. This Web site works best with Microsoft Internet Explorer 6.0 or later, Firefox 1.5, or Netscape Navigator 8.0 or later. Learn more about supported browsers.

Printer-Friendly VersionPrinter-Friendly Version Bookmark and ShareShare
Modify a date in Access by clicking the mouse
 
Applies to
Microsoft Access 2002

The original source of the code samples provided in this article is on http://www.applecore99.com.

In Access 2002, you can make a date value increment or decrement in response to the user clicking the left or right mouse button. For example, the Date Due text box displays the date a payment is due from the customer. The default value is set to 3/31/2002, but some customers are given three extra days. Rather than require the user to type 4/3/2002 each time, you could let them press the left mouse button three times to increment the value.

To implement this functionality, add code to the MouseDown event of the DueDate text box.

  1. In Design view, click the DueDate text box.
  2. Press F4 to display its property sheet.
  3. On the Event tab, move the focus to the MouseDown event.
  4. Click the Build button and choose Code Builder.
  5. In the Code window, add the following lines of code to the DueDate_MouseDown event procedure:
    Select Case Button
        Case 1 ' Left mouse click
            Me!BirthDate = DateAdd("d", _
              1, Me!BirthDate)
        Case 2 ' Right mouse click
            Me!BirthDate = DateAdd("d", _
              -1, Me!BirthDate)
    End Select

    By default, the right mouse button displays the shortcut menu, so you must disable it.

  6. Double-click the form selector on the top left corner of the form to display the form's property sheet.
  7. Set the Shortcut Menu property to No.
advertisement