Control Validation Rule

K

Kyle Jedrusiak

I'm using Access 10.x (Office XP) and SQL 8.x (2000).

I have a table designt that allows NULLs in a field due to issues with old
data.

If the user is entering a new record I would like to force them to select a
value.

I though I could use the control's validation rule propery.

The rule doesn't see to run as I go off the empty field for a new record.
But if I enter some data, then delete it, the rule does run.

Kyle!
 
R

Rick Brandt

Kyle Jedrusiak said:
I'm using Access 10.x (Office XP) and SQL 8.x (2000).

I have a table designt that allows NULLs in a field due to issues with old
data.

If the user is entering a new record I would like to force them to select a
value.

I though I could use the control's validation rule propery.

The rule doesn't see to run as I go off the empty field for a new record.
But if I enter some data, then delete it, the rule does run.

Correct, a Validation Rule will not work reliably here. Put a test in the
Form's BeforeUpdate event that displays a message and Cancels the update if
they don't make an entry.

EX:

Private Sub Form_BeforeUpdate(Cancel As Integer)

If Len(Nz(Me!ControlName,""))=0 Then
MsgBox "You must make an entry for Whatever"
Cancel = True
End If

End Sub
 

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

Top