Is there a data entry shortcut for Entering a Date? (1 Viewer)

ncimike3

Registered User.
Local time
Today, 03:33
Joined
Jan 5, 2011
Messages
12
I want to increase or decrease the date by 1 by simply using the plus or minus key when I'm in a Date field. If any of you have use quickbooks you would be familiar with this nifty data entry technique when in a date field. In my access form, when I go to a new record, the first field is the date field in which I have a default date entry automatically entetered and selected, waiting to be overwritten if so desired. Is there a way to use the plus or minus key to increment or decrement the date by one each time the key is pressed? Thanks for any help.

Mike
 

John Big Booty

AWF VIP
Local time
Today, 21:33
Joined
Aug 29, 2005
Messages
8,263
Welcome to the forum.

You could use the KeyDown event to detect the press of either the plus or minus key, and then use the DateAdd() function to add or subtract a day as appropriate.
 

boblarson

Smeghead
Local time
Today, 03:33
Joined
Jan 12, 2001
Messages
32,059
Welcome to the forum.

You could use the KeyDown event to detect the press of either the plus or minus key, and then use the DateAdd() function to add or subtract a day as appropriate.

You could, you could. Or you could import the module from Armen's database file and then just call it (no wheel rebuilding necessary since it is already built.). :D
 

John Big Booty

AWF VIP
Local time
Today, 21:33
Joined
Aug 29, 2005
Messages
8,263
Sorry to be Walter Cronkite (late news ;) ) just been playing and came up with this ;

Code:
Private Sub TDate_KeyDown(KeyCode As Integer, Shift As Integer)
    
    If KeyCode = 107 Then
        Me.TDate = DateAdd("d", 1, Me.TDate)
        KeyCode = 0
    ElseIf KeyCode = 109 Then
        Me.TDate = DateAdd("d", -1, Me.TDate)
        KeyCode = 0
    End If
        
    
End Sub
 
Last edited:

ncimike3

Registered User.
Local time
Today, 03:33
Joined
Jan 5, 2011
Messages
12
Thanks for the quick response. Your reply leads to a new question. The key down event won't know the difference between a numerical entry and a down arrow. Or will it? In quickbooks, you have the option of typing in the characters 0-9, and the / character to overwrite the existing date or if desired the plus or minus key to change the date incrementally. I only program sparatically so I'm not too sharp on my code these days. Thanks in advance.
 

ncimike3

Registered User.
Local time
Today, 03:33
Joined
Jan 5, 2011
Messages
12
ok. just saw the latest posts. Thanks guys. I'll give it a go and let ya know.
 

ncimike3

Registered User.
Local time
Today, 03:33
Joined
Jan 5, 2011
Messages
12
Bob, thanks. Looks like the code has already been written. I think I need some help implementing it. I've never imported a module before. Anywhere I can read on how to bring those tools in and use them?
 

ncimike3

Registered User.
Local time
Today, 03:33
Joined
Jan 5, 2011
Messages
12
Bob, thanks so much. I figured it out and it worked like a charm!
 

Users who are viewing this thread

Top Bottom