edit date

M

mccoy

how can i edit my date field by pressing + and - key

+ key will increase the date by a day and the - key is vice versa
 
L

Linq Adams via AccessMonster.com

Private Sub YourDateField_KeyPress(KeyAscii As Integer)
If KeyAscii = 43 Then
KeyAscii = 0
Me.YourDateField = Me.YourDateField + 1
ElseIf KeyAscii = 45 Then
KeyAscii = 0
Me.YourDateField = Me.YourDateField - 1
End If
End Sub


Or, for those who don’t like the Date + 1 syntax

Private Sub ExpDate_KeyPress(KeyAscii As Integer)
If KeyAscii = 43 Then
KeyAscii = 0
Me.ExpDate = DateAdd("d", 1, Me.ExpDate)
ElseIf KeyAscii = 45 Then
KeyAscii = 0
Me.ExpDate = DateAdd("d", -1, Me.ExpDate)
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top