troubleshooting Question

Quickbooks-style date increments/decrements?

Avatar of David Spigelman
David SpigelmanFlag for United States of America asked on
Microsoft AccessProgramming
7 Comments1 Solution394 ViewsLast Modified:
I'd like to setup a date field in an Access form, that can be incremented or decremented by pressing the + or - key, respectively, the way it works in Quickbooks. I thought that I could capture the keypress before saving the field, and do the job that way, by using code like this in the OnKeypress event:

Private Sub RequestDate_KeyPress(KeyAscii As Integer)
   Select Case KeyAscii
      Case 43
         RequestDate = RequestDate + 1
      Case 45
         RequestDate = RequestDate - 1
   End Select
End Sub

This seems to work, except that it still types a "+" or a "-" into the box. In fact, if the field value is highlighted, it erases the existing value to do it, although if I hit Esc afterwards, I can see that  the new, correct value, is in place.

How do I get it to just update the field with the new date value, and not insert a + or - into it?
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Database Architect / Application Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Top Expert 2007

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros