Help with simple Send Event

T

Theresa

Ok, so I am doing some basic form validation using VBScripts functions...if
they dont resolve I set the send function to false...can anyone tell me why
it still sends??
Function Item_Send()

If not isNumeric(item.userproperties("cost center")) then

Item_Send = False

msgbox "Cost Center must be numeric"

End If

End Function
 
C

carl lorentson

I believe you need something like the code below. Note the use of the
Cancel parameter. (Source: Ms Outlook VB Ref | Events | Send Event)

Function Item_Send(Cancel)

If not isNumeric(item.userproperties("cost center")) then

Cancel = True 'Item_Send = False

msgbox "Cost Center must be numeric"

End If

End Function

Hope that works,
Carl Lorentson
 
S

Sue Mosher [MVP]

The form-level Item_Send event does not have a cancel parameter. Item_Send = False is the correct way to cancel the send. I would start my troubleshooting by adding a MsgBox statement to display the value of item.userproperties("cost center")

--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
http://www.slipstick.com/books/jumpstart.htm
 
Joined
Mar 31, 2011
Messages
1
Reaction score
0
Hello Carl,
I had the same issue. This seemed to work for me.


My Program:

Function Item_Send()
Dim objSum

Dim objPage
Set objPage = Item.GetInspector.ModifiedFormPages("Message")
Set objSum = objPage.Controls("TxtSum")

If Trim(objSum.Value) = "" Then
Item_Send = False
MsgBox("Please enter the Summary.")
objSum.Setfocus
Exit Function
End If

Your Program:

Function Item_Send()

If not isNumeric(item.userproperties("cost center")) then

Item_Send = False

msgbox "Cost Center must be numeric"

' I added this and it seemed to work perfectly for my program.
Exit Function

End If

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top