Data entry shortcuts for dates

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an Acess 2000 applicatoin that's just loaded with dates. To help
speed up data entry, I'd like to find a way for the users to put in a
shortcut some how, like a letter in the date field and then let the system
insert the correct date. Most of the time, the dates they need will be
either today, yesterday or one week from today.
If the user enters a "c" into the ReceivedDate for example, I'd like to put
in today's date. If they put in a "y", I'd like yesterday's date and if they
put a "w" in the field, I'd like to calculate a future date one week from
today.
When I try to insert the code to do this, I get a message from Access that
the value entered isn't valid for the field. That's true, it's a date field
and I've put a character in there. I've tried both the before update and
after update event for the field.
Does anyone know how to get around this, or maybe even a better way to get
the job done?
 
Use the KeyPress event of the text box.
Check the KeyAscii value, and assign whatever value you want.

This kind of thing:

Select Case KeyAscii
Case 84, 116 ' T
KeyAscii = 0
Screen.ActiveControl = Date()

Case 89, 121 ' Y
KeyAscii = 0
Screen.ActiveControl = Date() - 1

Case 43 ' Plus key
KeyAscii = 0
Screen.ActiveControl = Screen.ActiveControl + 1

Case 45 ' Minus key
KeyAscii = 0
Screen.ActiveControl = Screen.ActiveControl - 1
End Select
 
That worked perfectly. Thank you very much.

Allen Browne said:
Use the KeyPress event of the text box.
Check the KeyAscii value, and assign whatever value you want.

This kind of thing:

Select Case KeyAscii
Case 84, 116 ' T
KeyAscii = 0
Screen.ActiveControl = Date()

Case 89, 121 ' Y
KeyAscii = 0
Screen.ActiveControl = Date() - 1

Case 43 ' Plus key
KeyAscii = 0
Screen.ActiveControl = Screen.ActiveControl + 1

Case 45 ' Minus key
KeyAscii = 0
Screen.ActiveControl = Screen.ActiveControl - 1
End Select
 
Back
Top