using + and - to change date

D.Mair

David
Local time
Today, 00:55
Joined
Jun 1, 2001
Messages
33
I have a date that inserts automatically and for speed users thought using + and - to increase and decrease the date by one day would be handy. I tried

Private Sub Received_Change()
If Me.[Received].Text = "+" Then
Me.[Received].Value = Me.[Received].Value + 1
ElseIf Me.[Received].Text = "-" Then
Me.[Received].Value = Me.[Received].Value - 1
End If

But this didn't work I think it is this part ("+" Then) I think i need something before the + sign

Thanks in anticipation.


[This message has been edited by D.Mair (edited 06-25-2001).]
 
Sure.. First, you have to lock the textbox by setting the Locked Property to Yes. Then all you have to do is put the following code in the KeyDown event of the text box...

If KeyCode = vbKeyAdd Then
Me!TxtDate = DateAdd("d", 1, Me!TxtDate)
ElseIf KeyCode = vbKeySubtract Then
Me!TxtDate = DateAdd("d", -1, Me!TxtDate)
End If

Then just have the date auto-populate and when the focus is on the box and you press the Plus or Minus key, it will add or subtract a day to the date in there. Hope that helped.

Doug
 
Thanks worked a treat.
But I don’t really want to lock the textbox. I want people to alter the date by typing if required i.e. date is + 10 days it would be quicker to type it in. any suggestions?

Thanks


[This message has been edited by D.Mair (edited 06-25-2001).]
 

Users who are viewing this thread

Back
Top Bottom