Link to home
Create AccountLog in
Microsoft Access

Microsoft Access

--

Questions

--

Followers

Top Experts

Avatar of kay soo
kay soo🇲🇾

Access VBA to create a virtual KeyPad in Form
Hi Experts, I am using Access 2003 as development tools on two computers running Windows 7 and Windows 10 respectively.

I am doing a customized POS project running on a TOUCH SCREEN terminal and seriously stuck at a wall...

As there's no physical key board attached, I am intended to use a few command buttons to represent 0-9 like normal keypad for numbering input to an unbound field for capturing payment tendered by customer, and let say the unbound field is named as me.payment

Please refer to the attached .jpeg
1. Assuming the unbound field is currently being focused, can anyone show me how to do the coding for the button to function just like normal keypad? eg. if Button 1 pressed, the unbound field supposed to show 1, if Button 2, 7 and 9 were pressed right after one after another, the unbound field supposed to read as 279, and so on, just like when we are using normal keypad.

and

2. And most importantly.....I need help on how's the VBA code when Button "Enter" is pressed to function just like normal keyboard's Enter key?

I hv searched up and down but no luck getting any example online that suitable to my problem, hope anyone can shed some lights of how to solve this.

Thx.
ButtonKeyPad.jpg

Zero AI Policy

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


ASKER CERTIFIED SOLUTION
Avatar of Gustav BrockGustav Brock🇩🇰

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Create Account

Avatar of kay sookay soo🇲🇾

ASKER

Noted with thanks for the numbering.

But is there a way how to do it something like sendkeys method for the Enter key instead of Public Function?
however please note Sendkeys seems not working in Windows 10, need so other alternative like SendKeys way of Enter if possible.

Avatar of PatHartmanPatHartman🇺🇸

The target field cannot have the focus if you want to use a screen keyboard.  That means that there can be only a single data entry field on the form or you you need some way of identifying the intended target of the number key values.

Gus' suggestion shows how to make the "number pad" fill the target field.  I'm not sure why you want it to be unbound.  You also need a backspace and a clear key.  The backspace will clear the last character entered into the field and the clear key will empty the whole field.  Then you need an "enter" key to apply the update.

I've used touchscreens at kiosks and they are terrible.  They lose sensitivity and miss characters or they stutter and produce duplicate characters.  I've never used a laptop or all in one for touchscreen entry.  They might be better.

External keyboards are a far better solution.  That way you can have multiple data entry fields.  You tab into the field where you want the keying to post and then use the keypad.  As I said, with the on screen "keypad", you either can have only a single target field or you must somehow determine ahead of time which field the key values post to.

Avatar of PatHartmanPatHartman🇺🇸

Why do you think you need to use send keys?

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


Avatar of kay sookay soo🇲🇾

ASKER

Hi Pat, thx for the explanation too, since I never come across Touch Screen and this is the first encounter, actually I m not sure what to expect.
Searching the keypad solution around, saw many comments online about the sendkeys function, but never tired before.

Avatar of Dale FyeDale Fye🇺🇸

SendKeys is generally considered "old school".

As Pat said, why do you feel that the field should be unbound.  With a bound field, the enter key could simply save the record.

It would be helpful to see a screen print of your screen layout.

Avatar of PatHartmanPatHartman🇺🇸

Sendkeys is useful if you are pasting data into a different application such as a web page.  In your own Access app, you would know the actual name of the target field and would address it by name rather than throwing a keystroke and hoping it ends up in the correct data field.  I think some Access generated macros might have used sendkeys and that may be why you see examples.  Personally, I can't remember a single time where I have used sendkeys in more than 25 years of coding with VBA.

Free T-shirt

Get a FREE t-shirt when you ask your first question.

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of kay sookay soo🇲🇾

ASKER

Thx guys, sorry been away form cubical for few days.

Managed to find a solution to settle the matter but without sendkeys function.  I misunderstood the SendKeys, thought it works just like key stroke when come to touch screen POS terminal (insists by Client).  

Mr. Pathartman, you were right, touch screen is a pain in the butt...

Avatar of kay sookay soo🇲🇾

ASKER

Hi Dale, this is how the GUI looks like on the design, after this retail POS app, next project is for FnB Industry, especially for FnB, mainly they all use Touch Screen in my Country. there will be even more buttons here and there in FnB app, more pain in the butt..
POS-Interface.jpg

Avatar of PatHartmanPatHartman🇺🇸

You have only a single clear key, you need to clear the whole entry and you also need to backspace to clear the last keystroke.

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.

Microsoft Access

Microsoft Access

--

Questions

--

Followers

Top Experts

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.