Textbox on Userform

M

Martin Beir

Two questions for the group.

Answers gratefully received.

I have placed a textbox on a Userform.
I have written code for the 'EXIT' event associated with this textbox:
"If Textbox1 (does not meet condition) Then Cancel=-1".
This is simple and prevents the User exiting the textbox without first
making a valid entry.

However, if I introduce a message box:
"If Textbox1 (does not meet condition) Then Msgbox "You must enter an
integer": Cancel=-1
I find that when the Message box is closed focus does not return fully to
the textbox. Pressing the delete key will erase text in the textbox but it
is not possible to make an entry in the textbox without first clicking the
textbox with mouse. Indeed, until the mouse is clicked on the textbox there
is no visible cursor.

Is there anyway of overcoming this?

If a user is prevented from exiting a control e.g. as example above, the
other controls on the Userform are effectively disabled as they cannot
receive focus. This is for the most part desirable but it would in some
cases be useful if the cancel button still functioned. A CommandButton with
code: "Unload Me" does not funtion if it is preventd from receiving focus.

Is it possible (other than using the red system button, top left-hand
corner) to create a "Super Control" which is not restricted?

I look forward to receiving your answers.

Seasons' Greetings to all,

Martin
 
J

J.E. McGimpsey

Martin Beir said:
I have placed a textbox on a Userform.
I have written code for the 'EXIT' event associated with this textbox:
"If Textbox1 (does not meet condition) Then Cancel=-1".
This is simple and prevents the User exiting the textbox without first
making a valid entry.

However, if I introduce a message box:
"If Textbox1 (does not meet condition) Then Msgbox "You must enter an
integer": Cancel=-1
I find that when the Message box is closed focus does not return fully to
the textbox. Pressing the delete key will erase text in the textbox but it
is not possible to make an entry in the textbox without first clicking the
textbox with mouse. Indeed, until the mouse is clicked on the textbox there
is no visible cursor.

Is there anyway of overcoming this?

I can reproduce this in XLv.X, but I haven't found a way around it,
so I've escalated it to MacBU. I'll post back if I get an answer. In
the meantime, please send MS feedback via the Help/Feedback on XL
menu item.
 
J

J.E. McGimpsey

J.E. McGimpsey said:
I can reproduce this in XLv.X, but I haven't found a way around it,
so I've escalated it to MacBU. I'll post back if I get an answer. In
the meantime, please send MS feedback via the Help/Feedback on XL
menu item.

Well, one workaround would be to kill the MsgBox and use a Label on
the Userform instead - that's my preferred method anyway, I hate to
force the user to dismiss a msgbox when a reminder on the form
itself (say in bold, red type) will do...
 
J

J.E. McGimpsey

Martin Beir said:
If a user is prevented from exiting a control e.g. as example above, the
other controls on the Userform are effectively disabled as they cannot
receive focus. This is for the most part desirable but it would in some
cases be useful if the cancel button still functioned. A CommandButton with
code: "Unload Me" does not funtion if it is preventd from receiving focus.

Is it possible (other than using the red system button, top left-hand
corner) to create a "Super Control" which is not restricted?

I look forward to receiving your answers.

I confirmed this in both XLv.X and XL01. I hesitate to call it a
bug, since it may be by design, but I agree that leaving the Cancel
button active makes sense. Again, I've found no workaround so I've
submitted the issue to MacBU. Please do the same. I'll post back if
I get an answer.
 
J

J.E. McGimpsey

J.E. McGimpsey said:
I confirmed this in both XLv.X and XL01. I hesitate to call it a
bug, since it may be by design, but I agree that leaving the Cancel
button active makes sense. Again, I've found no workaround so I've
submitted the issue to MacBU. Please do the same. I'll post back if
I get an answer.

Oops - I wasn't thinking straight - this behavior is by design,
rather than being a bug/problem - the Textbox's Exit event fires
before the Cancel Button's Click event, so the Cancel in the Exit
event procedure sets focus back to the Textbox and clears the Click
Event.

Your suggestion that there be some control that works like the close
window control is a good one, though!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top