Thank you Sue. The code does have (intMatchCount >= intReqCats) however, I'd
like the user to know why their contact isn't saving. Right now it just sits
there if they don't select the correct amount of categories. I'm not familiar
with (Err = 0) and how to create a message box.
Can all of the Required Category code be put into VBA and run that way?

Signature
Thank you,
scrowley@littleonline.com
> The real trouble is that VBScript doesn't support error handlers. It supports only On Error Resume Next. Couldn't you just check (intMatchCount >= intReqCats) and/or (Err = 0) at the end of your procedure?
> > Hello,
[quoted text clipped - 49 lines]
> > Exit Function
> > End Function
If Err <> 0 Then
MsgBox "Your text goes here"
End If
VBA is not suitable for building an application you're deploying to other people. A COM add-in could do it, but you'd have to install it for each user.

Signature
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
> Thank you Sue. The code does have (intMatchCount >= intReqCats) however, I'd
> like the user to know why their contact isn't saving. Right now it just sits
[quoted text clipped - 56 lines]
>> > Exit Function
>> > End Function
SCrowley - 16 Sep 2005 15:07 GMT
Thank you very much.

Signature
Thank you,
scrowley@littleonline.com
> If Err <> 0 Then
> MsgBox "Your text goes here"
[quoted text clipped - 61 lines]
> >> > Exit Function
> >> > End Function
SCrowley - 16 Sep 2005 15:38 GMT
I'm trying the If Err but I must be putting it in the wrong place.
I placed it under:
Function HasRequiredCategory()
Dim intMatchCount
Dim intReqCats
If Err <> 0 Then
MsgBox "Sorry, your contact will not save until you select categories as
instructed in the Red Box located to the left of the Categories box"
End If
'******USER OPTION*****
'number of category matches required
intReqCats = 2
Set objPage = Item.GetInspector.ModifiedFormPages("General")
Set objControl = objPage.Controls("lstCategories")
If gstrRequiredCats <> "" Then
arrCats = Split(UCase(Item.Categories),",")
arrRequiredCats = Split(gstrRequiredCats,";")
For I = 0 To UBound(arrCats, 1)
For J = 0 To UBound(arrRequiredCats, 1)
If Trim(arrCats(I)) = Trim(arrRequiredCats(J)) Then
intMatchCount = intMatchCount + 1
If intMatchCount >= intReqCats Then
Exit For
End If
End If
Next
If intMatchCount >= intReqCats Then
Exit For
End If
Next
End If
HasRequiredCategory = (intMatchCount >= intReqCats)
End Function

Signature
Thank you,
scrowley@littleonline.com
> If Err <> 0 Then
> MsgBox "Your text goes here"
[quoted text clipped - 61 lines]
> >> > Exit Function
> >> > End Function
Sue Mosher [MVP-Outlook] - 16 Sep 2005 15:52 GMT
Err returns 0 if there's no error and some other number if there is an error. If you check Err <> 0 at the beginning of your procedure, it will always be True. Therefore, you need to put it at the end of your procedure, after all any code which could result in an error has run.

Signature
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
> I'm trying the If Err but I must be putting it in the wrong place.
>
[quoted text clipped - 98 lines]
>> >> > Exit Function
>> >> > End Function
SCrowley - 16 Sep 2005 21:01 GMT
I'm wondering if I should use the Item_Write instead and in addition to
setting the focus back on the lstCategories box, also display a Message Box
asking the user to follow the instructions listed in Label13
I'm not sure which is the best and most succinct way to solve this issue.
Any suggestions? Thank you.
Here is the Item_Write code:
Function Item_Write()
If HasRequiredCategory() = False Then
Item_Write = False
Item.GetInspector.SetCurrentFormPage "General"
Set objPage = Item.GetInspector.ModifiedFormPages("General")
Set objControl = objPage.Controls("lstCategories")
objControl.SetFocus
End If
End Function

Signature
Thank you,
scrowley@littleonline.com
> Err returns 0 if there's no error and some other number if there is an error. If you check Err <> 0 at the beginning of your procedure, it will always be True. Therefore, you need to put it at the end of your procedure, after all any code which could result in an error has run.
>
[quoted text clipped - 100 lines]
> >> >> > Exit Function
> >> >> > End Function
Sue Mosher [MVP-Outlook] - 16 Sep 2005 21:18 GMT
I don't think it matters. It's mainly a matter of how you want to organize your code modules.

Signature
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
> I'm wondering if I should use the Item_Write instead and in addition to
> setting the focus back on the lstCategories box, also display a Message Box
[quoted text clipped - 119 lines]
>> >> >> > Exit Function
>> >> >> > End Function