Validation Rules

Hellfire

Registered User.
Local time
Today, 19:08
Joined
Jul 23, 2002
Messages
57
I am stuck!!

Please help me with the validation rules for certain field.

I have a text field called Sender_out if this fiels left blank I want an error message to be displayed.

Please help me with the format of this validation rule.

The field is a combo-box, linked to a table with names in. if I set the Validation rule to Is Null, and select a name from the box, the error message is still displayed. How do I get it to ONLY Display when the box is left completely blank?

Please help.
 
Try this function Courtesy of Rich

Public Function fnValidateForm(frmA As Form) As Boolean
Dim ctl As Control
Dim Msg, Style, Title, Response, MyString
fnValidateForm = True
For Each ctl In frmA.Controls
'value in the control is required
If InStr(1, ctl.Tag, "Required") > 0 Then
' no value entered or value is null
' or zero for numeric fields
If (IsNull(ctl.Value)) Or (Len(ctl.Value) = 0) Then
ctl.SetFocus
MsgBox "You have not entered all the required fields return to the record and correct this! The record will not be saved if you do not! "
fnValidateForm = False

Exit For
End If

If InStr(1, ctl.Tag, "NumberRequired") > 0 Then
If ctl.Value = 0 Then
ctl.SetFocus
MsgBox "You have not entered all the required fields return to the record and correct this! The record will not be saved if you do not! "
fnValidateForm = False

Exit For
End If
End If
End If

Next
End Function

Set the tags of the fields you want completed to Required (for a text field) or NumberRequired (for a numeric field - remember if your combo stores a value you want to set the tag to NumberRequired;) )

In the Before_Update of the form
If fnValidateForm(me) = false then
cancel = true
end if

This will now not allow you to move off this form until all the relevant fields are completed and it jumps to the culprit field.
 

Users who are viewing this thread

Back
Top Bottom