Help With Some Form Data Validation

R

RRLady

I have two query created calculated fields on a form. Each field has
separate data input to calculate the query.

When all data has been correctly input and the fields are calculated, the
result in both calculated fields should be the equal.

What I would like is a Form Data Validation that compares the two calculated
fields values before the record is saved.

If the values are the same, then the record can be saved. If the values are
not the same, a message needs to be displayed to indicate the user should
check their input on the form to get the same answer in both fields.

I do now know how to build this validation. I assume it would be a macro
that is attached to the form.

Can anyone help me with this?

Thank You!

RRLady
 
J

Joan Wild

RRLady said:
I have two query created calculated fields on a form. Each field has
separate data input to calculate the query.

When all data has been correctly input and the fields are calculated, the
result in both calculated fields should be the equal.

What I would like is a Form Data Validation that compares the two
calculated
fields values before the record is saved.

If the values are the same, then the record can be saved. If the values
are
not the same, a message needs to be displayed to indicate the user should
check their input on the form to get the same answer in both fields.

I do now know how to build this validation. I assume it would be a macro
that is attached to the form.

Can anyone help me with this?


In the form's Before Update property choose Event Procedure and then click
on the build button (...)

Between the lines
Private Sub Form_BeforeUpdate(Cancel As Integer)

End Sub
put

If Me!txtOne <> Me!txtTwo Then
MsgBox "Check your entries.", vbOKOnly
Cancel = True
End If

Change txtOne and txtTwo in the above to match the names of the controls on
your form that hold the calculations.
 
Top