Validation of Form based on three fields

joepineapples

Registered User.
Local time
Today, 02:38
Joined
Apr 28, 2006
Messages
29
I have a Form called Demographics.

On this form there are several fields three of which are relevant to my query.

1. Reported
2. Male
3. Female

What I want to be able to do is to check that the total of Male and Female equals Reported. If not then display message box "Error etc".

I would want to activate the validation before the form is closed or it moves to a different record.

I'm guessing this can be done in code but my knowledge is quite limited.

Any help would be much appriciated.
 
In the forms before update event use something along the lines of
Code:
If Nz(Me.Male) + Nz(Me.Female) <> Nz(Me.reported) Then
    MsgBox "Your Error Message", vbCritical
    Cancel = True
End If

HTH

Peter
 
Cheers. That works a treat.

JP:)
 

Users who are viewing this thread

Back
Top Bottom