Help with my Keypad

Local time
Today, 05:31
Joined
Feb 14, 2025
Messages
36
Hi All
I am designing a 'Key Pad' to be used as a subform within a Till Page, one to ensure only numbers are entered and to ease use on a touch screen monitor.

It is a simple form with a textbox to store the numbers entered and 12 buttons, 0 to 9, a back button and a "." button. I have the vba working for each number button, for example [NumberEntered] = [NumberEntered] & "1" and the back button working where it cuts the last number off the text box only if the length is bigger than zero (trying to delete number from a zero content text box crashes the vba so this check is necessary.

I am trying to now validate the user entries and stop the idiot entries, for example £123.56.78 is not a possible number, so I would like to stop the user entering two "."

I thought about checking if the 3rd from right character is a period, and if so doing nothing if the period button is pressed, this would stop the user being able to enter a text with 2 periods but am unsure how to do this, In String and In string reverse returns the character position from the left and I need it from the right.

Similarily, I need to also validate that i have only 2 characters after the period so the user cant enter a payment of for example £23.167

any thoughts, and am I tackling this the correct way.

Thanks

Chris
 
You could check for the period and if not at position = length of text less 3, just message Invalid Amount?
That would catch more than one and also 3 decimal places.
I would also use [NumberEntered] = [NumberEntered] & Me.Caption for the numeric buttons, not hardcode them, then you could have a common function for all the numeric buttons.
 
think you need to include a 'back' button in case the user mistypes. You can also disable the period button after it has been tapped

txtPeriod.enabled=instr(txtResult,".")=0

so it re-enables if the user backs over it

and disable all buttons(except the back button) with

txtNumbers.enabled=len(mid(txtresult,instr(txtresult,".")))<3

And why are you using the £ in your examples - is the till multi currency?
 
HI
Thanks, food for thought.
I do like the idea of using the me.capture method, i didnt think about that.
I do have a back button on the keypad and have it working, and also like the idea to disable the period button once pressed.

I don't have the £ sign in the actual form or the text box, i put it in my post just to give the example of someone entering two periods.

I note from our card machine that the entries seem to roll, in that with each number entered the machine also automatically places the period in the third last position and as you had more numbers the numbers scroll right to left, for example for 10.35, the screen displays with each press 0.01, 0.10, 1.03, and finally 10.35. with this method the period remains fixed in the correct position and there will always only be two digits after the period, but i thought that would be more difficult for me to code, so I went for the easier option.
 
Last edited:
Hi
The input mask does seem the simplest, and after a few tries, the following works nearly
!#aa.aa;0;

it even 'scrolls' like mentioned earlier. My only issue now is that due to it being an unbound text box and not bound to a table field where I can control the max length of digits, you can keep pressing and adding more digits. A simple length check when pressing the number button should solve that. Also, no need to have a period button as it is placed automatically.

Thanks for all the help
 

Users who are viewing this thread

Back
Top Bottom