edit date

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

Guest

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
 
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
 
Back
Top