Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 280
Default Help coding userform

If you set Cancel True in the Exit event handler, focus will return to the
control that generated the Exit event. From the user's point of view, focus
never leaves the control.

By "target field", do you mean where the focus will land next if Cancel is
not set to True? The Enter event will have to fire before you know that,
unless you monitor every mouse click and keypress and sort of "manhandle"
the focus.

I might suggest that you validate on the OK click event and save youself
some trouble, if that works for you. Another suggestion I have seen is to
use labels instead of textboxes. Move a textbox around from label to label
for user editing. You can make a label look like a textbox except it will
not be user editable. It will look to the user as if they are tabing around,
but it may be easier to control. (I have heard this suggested, not
implemented it myself, but it sounds doable.)

Bob Kilmer

"Mike NG" wrote in message
...
If I have a userform which looks something like

______________
TextBox1 |_____________|
TextBox2 |_____________|
TextBox3 |_____________|
TextBox4 |_____________|

OK Cancel

I want to run some field exit validation e.g. validating post code
formats, checking values are in a certain range - i.e. not candidates
for the _Change event

The event must run if the user uses the TAB key or the mouse to go to
another field - a field in error will display a msgbox and focus must be
sent back to the field in error, but not if the Cancel button is
*clicked*


The only way I can see focus being driven back to the field is if Cancel
is set to true within the _Exit event, but I can't work out how to
detect what the target field is going to be as a result of the _Exit
event, whilst still in the _Exit event

_Entry would seem like a logical place to call a common validation
routine, but SetFocus doesn't behave as expected


Any pointers would be greatly appreciated
--
Mike



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VB Coding johnsail Excel Discussion (Misc queries) 1 February 18th 10 12:54 PM
sum by coding without 0 kaja New Users to Excel 2 March 1st 08 03:52 PM
How to fix the coding? Eric Excel Worksheet Functions 0 February 26th 08 03:38 AM
coding maisy1 Excel Discussion (Misc queries) 1 August 6th 06 08:58 PM
coding Hardy Excel Discussion (Misc queries) 1 February 22nd 05 04:58 PM


All times are GMT +1. The time now is 04:11 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"