User scroll dates question

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

Guest

I have a date control that when the form loads displays the current date.
What code/process do I need to do so when the user hits the + or - key the
date changes?

Thanks
 
Make a Public Function for this:

Function ChangeDate(KeyAscii As Integer, ActiveControl As Control) As
Integer

Select Case KeyAscii
Case 43
If IsDate(ActiveControl) Then
ActiveControl = ActiveControl + 1
Else
ActiveControl = Date()
End If

ChangeDate = 0
Case 45
If IsDate(ActiveControl) Then
ActiveControl = ActiveControl - 1
Else
ActiveControl = Date()
End If

ChangeDate = 0
Case Else
ChangeDate = KeyAscii
End Select

End Function

Then, you'd use the function in any KeyPress event like this:

KeyAscii = ChangeDate(KeyAscii,Me.ActiveControl)
 
Back
Top