• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 172
  • Last Modified:

Lost Focus Problem with Default and Cancel Properties

I have some Text controls with code in the LostFocus Events for them and these work fine until the user Presses ENTER or ESCAPE. I know the reason my code stops working is becoause the ENTER and ESCAPE keys are taking effect without a LostFocus Event being triggered for the Text Boxes.
Does anyone know how to stop this happening.
I do need to have the Default and Cancel properties set for the 2 Command Buttons as well as the LostFocus code.
0
Merlin_UK
Asked:
Merlin_UK
  • 4
  • 3
1 Solution
 
simonbennettCommented:
Can you not check on the forms KeyPress event to check for enter or escape, get the activecontrol and then runs its lost focus code?

HTH

Simon
0
 
watyCommented:
You have one command buton with the default property set to true
and another (or the same) with the cancel property set to true
0
 
Merlin_UKAuthor Commented:
Yes Waty
My original question didn;'t stress that I need 2 command buttons, on with default proprty set to true and one with Cancel property set to true.
because of this, the escape and enter keys kick in BEFORE the loastfocus events of the other controls.
I would still like to have the Default and CAncel properties set but I must have the LostFocus working every time.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Merlin_UKAuthor Commented:
Simon
Your idea looks good
I'm testing at the moment
How do I know the Active Contol ??

0
 
watyCommented:
To know the active control :
screen.activeControl

But I suggest that you remove those Default and Cancel property and in each lostfocus event, if the user has pressed enter or Escape, call explicitelly the click event of you 2 buttons
0
 
Merlin_UKAuthor Commented:
Simon
Your idea looks good
I'm testing at the moment
How do I know the Active Contol ??

0
 
Merlin_UKAuthor Commented:
Waty
That's what I was thinking of doing, trouble is I know it's bad form, but I have 15 Text Boxes all with different names ........
Guess I'll have to re-name them in a control array like I should have done in the first place
Thanks for your help mate
0
 
watyCommented:
Some tips,

I use a lot the scree.activecontrol

like in the gotfocus event to select all the text, so I simply copy & paste the code from 1 gotfocus to another :)
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now