Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook - Using Forms (http://www.outlookbanter.com/outlook-using-forms/)
-   -   VBSCRIPT Validate (http://www.outlookbanter.com/outlook-using-forms/43938-vbscript-validate.html)

Juls March 20th 07 11:10 PM

VBSCRIPT Validate
 
Hi, for my custom form I have the following code:

Sub Item_Write()
If Item.UserProperties("Development Completed") #1/1/4501# and _
Item.UserProperties("Version Changed") = "" Then
msgbox ("error")
End If
End Sub

Currently when this clasue is trapped a message box appears showing an error
so I know the syntax is correct. At this point how do I
a) Prevent the form from being closed
b) Navigate the user to the field that is causing the error.

Thank-you/

Sue Mosher [MVP-Outlook] March 20th 07 11:40 PM

VBSCRIPT Validate
 
a) Rewrite the procedure as a Function (which the Script | Event Handler command in the form code window would have done for you) and add an Item_write = False statement where you want the item not to be saved.

b) Use the SetFocus method on the desired control. See http://www.outlookcode.com/d/propsyntax.htm#unbound if you need a primer on control syntax. s

--
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

"Juls" wrote in message ...
Hi, for my custom form I have the following code:

Sub Item_Write()
If Item.UserProperties("Development Completed") #1/1/4501# and _
Item.UserProperties("Version Changed") = "" Then
msgbox ("error")
End If
End Sub

Currently when this clasue is trapped a message box appears showing an error
so I know the syntax is correct. At this point how do I
a) Prevent the form from being closed
b) Navigate the user to the field that is causing the error.

Thank-you/


Juls March 21st 07 02:06 AM

VBSCRIPT Validate
 
Thanks - can I also programmatically change to the tab with the field in
question ?

"Sue Mosher [MVP-Outlook]" wrote:

a) Rewrite the procedure as a Function (which the Script | Event Handler command in the form code window would have done for you) and add an Item_write = False statement where you want the item not to be saved.

b) Use the SetFocus method on the desired control. See http://www.outlookcode.com/d/propsyntax.htm#unbound if you need a primer on control syntax. s

--
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

"Juls" wrote in message ...
Hi, for my custom form I have the following code:

Sub Item_Write()
If Item.UserProperties("Development Completed") #1/1/4501# and _
Item.UserProperties("Version Changed") = "" Then
msgbox ("error")
End If
End Sub

Currently when this clasue is trapped a message box appears showing an error
so I know the syntax is correct. At this point how do I
a) Prevent the form from being closed
b) Navigate the user to the field that is causing the error.

Thank-you/



Sue Mosher [MVP-Outlook] March 21st 07 03:30 AM

VBSCRIPT Validate
 
Yes, using the Inspector.SetCurrentFormPage method. (You do know about the object browser, right? F2 in VBA)

--
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

"Juls" wrote in message ...
Thanks - can I also programmatically change to the tab with the field in
question ?

"Sue Mosher [MVP-Outlook]" wrote:

a) Rewrite the procedure as a Function (which the Script | Event Handler command in the form code window would have done for you) and add an Item_write = False statement where you want the item not to be saved.

b) Use the SetFocus method on the desired control. See http://www.outlookcode.com/d/propsyntax.htm#unbound if you need a primer on control syntax. s



"Juls" wrote in message ...
Hi, for my custom form I have the following code:

Sub Item_Write()
If Item.UserProperties("Development Completed") #1/1/4501# and _
Item.UserProperties("Version Changed") = "" Then
msgbox ("error")
End If
End Sub

Currently when this clasue is trapped a message box appears showing an error
so I know the syntax is correct. At this point how do I
a) Prevent the form from being closed
b) Navigate the user to the field that is causing the error.

Thank-you/



Juls March 22nd 07 04:31 AM

VBSCRIPT Validate
 
I do now thanks.

"Sue Mosher [MVP-Outlook]" wrote:

Yes, using the Inspector.SetCurrentFormPage method. (You do know about the object browser, right? F2 in VBA)

--
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

"Juls" wrote in message ...
Thanks - can I also programmatically change to the tab with the field in
question ?

"Sue Mosher [MVP-Outlook]" wrote:

a) Rewrite the procedure as a Function (which the Script | Event Handler command in the form code window would have done for you) and add an Item_write = False statement where you want the item not to be saved.

b) Use the SetFocus method on the desired control. See http://www.outlookcode.com/d/propsyntax.htm#unbound if you need a primer on control syntax. s



"Juls" wrote in message ...
Hi, for my custom form I have the following code:

Sub Item_Write()
If Item.UserProperties("Development Completed") #1/1/4501# and _
Item.UserProperties("Version Changed") = "" Then
msgbox ("error")
End If
End Sub

Currently when this clasue is trapped a message box appears showing an error
so I know the syntax is correct. At this point how do I
a) Prevent the form from being closed
b) Navigate the user to the field that is causing the error.

Thank-you/




All times are GMT +1. The time now is 09:19 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com