We help IT Professionals succeed at work.
Get Started

Quickbooks-style date increments/decrements?

392 Views
Last Modified: 2012-05-11
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?
Comment
Watch Question
Database Architect / Application Developer
CERTIFIED EXPERT
Top Expert 2007
Commented:
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE