A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook - Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

One more...let's focus!



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 1st 06, 09:41 PM posted to microsoft.public.outlook.program_forms
robert
external usenet poster
 
Posts: 127
Default One more...let's focus!

I've got a custom property to validate two fields. I want to validate as the
user exits the field (rather than using the field validation done at form
close). If the value is outside the script logic, I clear it.

Problem is, I can't seem to find a way to put the focus back on the control
(text box) that created the validation error.

Where is setfocus or .focus or "go to this control" in VB Script? I guess I
really should have done all this in VBA but my boss wanted an
"organizational" form on our exchange server.

TIAs,
Robert
Ads
  #2  
Old March 1st 06, 11:42 PM posted to microsoft.public.outlook.program_forms
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default One more...let's focus!

SetFocus is a method of each control. You need to show the correct page, get the control, then use SetFocus:

Set insp = Item.GetInspector
Set page = insp.ModifiedFormPages("your custom page")
Set ctrl = page.Controls("name of your control")
insp.SetCurrentFormPage "your custom page"
ctrl.SetFocus

Unfortunately, it doesn't work 100% of the time.

Another tactic would be to turn the control's text red by setting its ForeColor property. See http://www.outlookcode.com/d/propsyntax.htm#unbound for more information on working with controls

That page also covers the CustomPropertyChange event that you'd need to use to respond to the user entering data for a particular property.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"Robert" wrote in message ...
I've got a custom property to validate two fields. I want to validate as the
user exits the field (rather than using the field validation done at form
close). If the value is outside the script logic, I clear it.

Problem is, I can't seem to find a way to put the focus back on the control
(text box) that created the validation error.

Where is setfocus or .focus or "go to this control" in VB Script? I guess I
really should have done all this in VBA but my boss wanted an
"organizational" form on our exchange server.

TIAs,
Robert

  #3  
Old March 3rd 06, 05:36 PM posted to microsoft.public.outlook.program_forms
robert
external usenet poster
 
Posts: 127
Default One more...let's focus!

Sue,

Thanks for your help, you've always been quick to respond.

Unfortunately, this technique didn't work, in fact I had tried something
very similar. The setfocus is within a Select Case statement. I don't know if
that would have anything to do with it not working.

The color change option isn't appropriate as it doesn't "force" the user to
change the field value. What I'm doing is this: using the custom property, if
the value of the field is greater than 2400 (military time) then display
warning, clear the value and (here's the doesn't work part) shift focus back
to the field in question. Since the custom property fires after exiting the
field by the time the other code executes focus has moved to the next field.

Here's a snippet:

case "txtFromTime","txtUntilTime"
Set insp = Item.GetInspector
Set page = insp.ModifiedFormPages("Message")
If strPropName = "txtFromTime" Then
Set strField = page.txtFromTime
Else
set strField = page.txtUntilTime
End If
set strHours = page.intHours
intValue = int(strField.value)
strMessage ="You have entered an invalid time!" & vbCrLF & "Please
re-enter a time using Military Format!"
IF intValue 2400 Then
msgbox strMessage, vbCritical,"A T T E N T I O N"
strField.Value = ""
strHours.Value = Null
strField.SetFocus


"Sue Mosher [MVP-Outlook]" wrote:

SetFocus is a method of each control. You need to show the correct page, get the control, then use SetFocus:

Set insp = Item.GetInspector
Set page = insp.ModifiedFormPages("your custom page")
Set ctrl = page.Controls("name of your control")
insp.SetCurrentFormPage "your custom page"
ctrl.SetFocus

Unfortunately, it doesn't work 100% of the time.

Another tactic would be to turn the control's text red by setting its ForeColor property. See http://www.outlookcode.com/d/propsyntax.htm#unbound for more information on working with controls

That page also covers the CustomPropertyChange event that you'd need to use to respond to the user entering data for a particular property.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"Robert" wrote in message ...
I've got a custom property to validate two fields. I want to validate as the
user exits the field (rather than using the field validation done at form
close). If the value is outside the script logic, I clear it.

Problem is, I can't seem to find a way to put the focus back on the control
(text box) that created the validation error.

Where is setfocus or .focus or "go to this control" in VB Script? I guess I
really should have done all this in VBA but my boss wanted an
"organizational" form on our exchange server.

TIAs,
Robert


  #4  
Old March 3rd 06, 07:07 PM posted to microsoft.public.outlook.program_forms
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default One more...let's focus!

That's why I generally do validation in the Item_Send or Item_Write event handler. You can certainly blank the control and put up a message, though.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"Robert" wrote in message news
Sue,

Thanks for your help, you've always been quick to respond.

Unfortunately, this technique didn't work, in fact I had tried something
very similar. The setfocus is within a Select Case statement. I don't know if
that would have anything to do with it not working.

The color change option isn't appropriate as it doesn't "force" the user to
change the field value. What I'm doing is this: using the custom property, if
the value of the field is greater than 2400 (military time) then display
warning, clear the value and (here's the doesn't work part) shift focus back
to the field in question. Since the custom property fires after exiting the
field by the time the other code executes focus has moved to the next field.

Here's a snippet:

case "txtFromTime","txtUntilTime"
Set insp = Item.GetInspector
Set page = insp.ModifiedFormPages("Message")
If strPropName = "txtFromTime" Then
Set strField = page.txtFromTime
Else
set strField = page.txtUntilTime
End If
set strHours = page.intHours
intValue = int(strField.value)
strMessage ="You have entered an invalid time!" & vbCrLF & "Please
re-enter a time using Military Format!"
IF intValue 2400 Then
msgbox strMessage, vbCritical,"A T T E N T I O N"
strField.Value = ""
strHours.Value = Null
strField.SetFocus


"Sue Mosher [MVP-Outlook]" wrote:

SetFocus is a method of each control. You need to show the correct page, get the control, then use SetFocus:

Set insp = Item.GetInspector
Set page = insp.ModifiedFormPages("your custom page")
Set ctrl = page.Controls("name of your control")
insp.SetCurrentFormPage "your custom page"
ctrl.SetFocus

Unfortunately, it doesn't work 100% of the time.

Another tactic would be to turn the control's text red by setting its ForeColor property. See http://www.outlookcode.com/d/propsyntax.htm#unbound for more information on working with controls

That page also covers the CustomPropertyChange event that you'd need to use to respond to the user entering data for a particular property.



"Robert" wrote in message ...
I've got a custom property to validate two fields. I want to validate as the
user exits the field (rather than using the field validation done at form
close). If the value is outside the script logic, I clear it.

Problem is, I can't seem to find a way to put the focus back on the control
(text box) that created the validation error.

Where is setfocus or .focus or "go to this control" in VB Script? I guess I
really should have done all this in VBA but my boss wanted an
"organizational" form on our exchange server.

TIAs,
Robert


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
focus date in calender on opening Chuck Outlook - Calandaring 2 February 1st 06 01:48 AM


All times are GMT +1. The time now is 09:06 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.