![]() |
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. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
focus date in calender on opening | Chuck | Outlook - Calandaring | 2 | February 1st 06 01:48 AM |