KeyUp problem

I use a series of messageboxs to direct the program flow.
When it gets to the last one, it is apparently passing the Keyup to the Button_Execute which fires on its own!

MsgBox (xS141) ’ “Place weight on selected Lift”
Button_Execute.Visible = True ’ show execute button
Button_Execute.SetFocus()
MM3.Refresh()

I keep trying, but I can’t figure out a way to intercept it!

the code in the Button_Execute Keyup event is :

if asc(key)=asc_CR or asc(key) = asc_Ent then ’ ENTER
me.Refresh
call ProblemStart()

end

if you close the message box by pressing ENTER, but the Button_execute has the focus, then letting go of the ENTER button is causing this code.

Why are you trapping CR in the key up?
A button should just have code in the Action Event.
if someone uses the mouse or the keyboard, the button shouldnt care.
You tend to do this kind of stuff if you are using a canvas as a button substitute

Yes, Button_Execute is a canvas.

Okay, so it works when I remove the line giving it focus.
Thanks!

I would have liked to let it have focus so the user can just hit enter again when they are ready to execute.
but I can live with it.

I am still having a problem with this.
The user clicks on the NewProblem Button which is based on a canvas.
There is a series of 3 messagedialogs which asks the user to make a choice between “Lift 1” or “Lift 2” and then “Mass” or “Pressure” etc.
Then there is a modal window that ask the User to enter a Pressure.
After that there is a final messagedialog that gets the OK from the user to start the pump when they are ready.
This all works fine if they only use the mouse, but if they use the Enter key on the window or the final dialog, the key gets passed back to the NewProblem Button which start it all over again.
This was all done in one method, so I thought I would be smart and break it up.
I took the answer from the first dialog and saved it in a textfield.
The TextChange event for that textfield then calls a method to open the next dialog etc etc.
The modal window saves the Pressure in a textfield and that TextChange event calls the final dialog.
I thought this would break the chain passing the key back to the initial button but it doesn’t! The key gets passed all the way up the chain!
What can I do?

Use Return at the end of the Event to eat the character.

I’ve placed Returns in many places. I haven’t found any that work yet.
This is only a problem on Mac. Windows works fine!

Please share a skeleton that demonstrate the trouble.

I found a solution.
At the start of the routine I set the focus to a label so it doesn’t come back to the button.

You could put Button_Execute.SetFocus in a short-period timer. That would allow the key press to completely finish before the button gets focus.