Require population (Validation) of all fields in Outlook 2003 Post Form

May 29, 2007
Reaction score
Selecting "A value is required for this field" or "Validate this field before closing the form" w/ Formula [TextFieldName] <> "" in form design, does not work - the form is still able to be submitted. What code can I use and where, to accomplish this? Following is the code for my form:

'Computer-Support Request Form

Dim m_blnUserSent
Const olDiscard = 1

Function Item_Write()
MsgBox "Please click the Submit button when " & _
"you have completed the form."
Item_Write = False
End Function

Function Item_Close ()
Dim intRes
Dim strMsg
If Not M_blnUserSent Then
strMsg = "You have not yet sent this request. " & _
"Do you really want to discard it?"
intRes = MsgBox (strMsg, vbYesNo + vbQuestion, _
"Abandon Request")
If intRes = vbNo Then
Item_Close = False
Item.Close olDiscard
End if
End If
End Function

Sub cmdSubmit_Click ()
Dim strDetails
Dim objForward
On Error Resume Next
strDetails = Item.Body
Item.BodyFormat = 1
strBody = AddLine ("Floors") & _
AddLine ("Dept.") & _
AddLine ("Extension") & _
AddLine ("Cat") & _
AddLine ("Product") & _
AddLine ("Symptoms") & _
AddLine ("Priorities")
If strDetails <> "" Then
strBody = strBody & vbCrLf & strDetails
End If
Set objForward = Item.Forward
objForward.Body = strBody
If Err = 0 Then
m_blnUserSent = True
msgBox "Request has been submitted. If this " & _
"issue is not addressed in a timely manner, it " & _
"will be automatically escalated. Please " & _
"do not re-submit this request." , , _
"Computer Support Request"
MsgBox "Request has not been submitted. Error occurred.", , _
"Computer Support Request"
End If
Set objForward = Nothing
End Sub

Function AddLine (strProp)
Dim objProp
Dim strLine
On Error Resume Next
Set objProp = Item.UserProperties (strProp)
strLine = strProp & " : "
If Not objProp Is Nothing Then
strLine = strLine & objProp.Value
strLine = strLine & "Property not available"
End If
AddLine = strLine & vbCrLf
End Function

I don't understand how to do this exactly, as this is all very new to me (less than a week into it). The form is pretty much doing what is needed so far, except allowing the form to be sent with empty fields. Can you provide an example of the code I need to use to do this, and tell me where to place it? I've placed:

"If Item.Floor = " " Then
msgBox "Please select a floor." , , _
"Computer Support Request"
Item_Forward = False"

beneath "objForward.Body = strBody", and the message is still being forwarded after the error box is cleared. Your help is greatly appreciated.

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