User scroll dates question

W

Wylie C

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
 
P

Paul Overway

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)
 

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