Solved Form.KeyDown not working with buttons (1 Viewer)

Teggun

Registered User.
Local time
Today, 05:34
Joined
Aug 30, 2019
Messages
33
Hi guys,

I'm having a trouble with a form where I am using a KeyDown and KeyUp event to enter a pin and log in the database, and it works nicely when all the elements on it are labels, but it appears that when adding a button on it it stops working. I think this is because the button gets the focus when loading the form and prevents the events to work.
Is there any solution to make this whole set work when having some buttons in the form?

Thanks in advance for your time and help.
 

isladogs

MVP / VIP
Local time
Today, 04:34
Joined
Jan 14, 2017
Messages
18,261
Set the focus to the textbox where the PIN is entered
 

Teggun

Registered User.
Local time
Today, 05:34
Joined
Aug 30, 2019
Messages
33
The problem is that can't set focus on it as the text box is not enabled. This is because I need the user to not type directly on it, but using numbers on the keyboard or clicking the numbers in the form.
In the set up, the only buttons are "Entrar/In" and "Salir/Out".
Any idea how I could make this work?

IMG.png
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:34
Joined
May 7, 2009
Messages
19,246
set the Main Form's Key Preview property to Yes.
 

Gasman

Enthusiastic Amateur
Local time
Today, 04:34
Joined
Sep 21, 2011
Messages
14,439
So set the control to Locked and Enabled = Yes?
 

isladogs

MVP / VIP
Local time
Today, 04:34
Joined
Jan 14, 2017
Messages
18,261
Agree with the above and set focus to one of the numbers on the form
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:34
Joined
May 7, 2009
Messages
19,246
see this demo the txtPin is Disabled.
and setting the Form's Key Preview property to Yes.
 

Attachments

  • RemotoControl.accdb
    488 KB · Views: 73

Users who are viewing this thread

Top Bottom