Help with simple Send Event

  • Thread starter Thread starter Theresa
  • Start date Start date
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
 
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
 
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
 
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
 
Back
Top