Allen Browne Date Roll Question!

B

Bob V

This works on my Letter Key pad but not my Number Pad unless I Turn off Num
Lock
Can this be used with Number Key Pad ............Thanks Bob

To provide this functionality in Access, attach this Event Procedure to the
KeyPress event of your control.

Select Case KeyAscii
Case 43 ' Plus key
KeyAscii = 0
Screen.ActiveControl = Screen.ActiveControl + 1
Case 45 ' Minus key
KeyAscii = 0
Screen.ActiveControl = Screen.ActiveControl - 1
End Select
 
A

Allen Browne

Very strange: on my machine it works on both the keypad +/- and also the
ones in the top row.

Some notepads have odd numeric keypads built into the main keyboard. Haven't
tested with that arrangement, but KeyAscii should recognise it.

Are you sure you're using KeyPress and not KeyDown?
 
B

Bob V

Thanks Allen for the reply. Actually its working on all my number text boxes
but its giving me a yellow line on
Screen.ActiveControl = Screen.ActiveControl + 1
If I use the plus button, on any date text box I have, Numbers and dates
should they be the same?
Thanks Bob
 
B

Bob V

Think I have found the cause of the error, If the text box is Unbound and
have no Control Source The code will not work, Is this Right?.....Regards
Bob
 
A

Allen Browne

For an unbound text box, try setting the Format property to Short Date so
Access has a clue about what data type is meant to be there.
 
A

Allen Browne

In that case, the text box has a Value that is non-date and non-numeric.

That could happen if you assigned a zero-length string to it, or a string
value rather than a number or date. It could also happen if the string was
the default value.

You can ask Access how it understands the value in the control. Open the
Immediate Window (Ctrl+G) and enter something like this:
? TypeName(Forms!Form1!Text0)
 
B

Bob V

If I cant get this to work, can I use 2 buttons + and - then whatever has
focus the date will Minus or plus??
Thanks for any help...........Bob
 
A

Allen Browne

You're going to hit the same problem with that approach, Bob.

If Access doesn't consider the value numeric, you cannot perform math on it.
For example, subtracting one from a space or zero-length string is a
nonsense, and will give give an error.
 

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