Validation Rule

L

Luis

Hello.
I have a continuous form with 3 text boxes (ID, Tx1,Txt2). I'm trying to
create a script that only allows users to move to another record if Txt1 and
Txt are not null.

ID is unique.

Can anyone give me a hint?

Thanks.

Luis
 
D

DavidBoyle

Go into your form and in the properties set the allow additions property of
the form to no, you are going to manipulate this property in code.


Put this code in the form's after update event - txt1 and txt2 are the names
of your controls:

Me.AllowAdditions =true
If IsNull(Me.txt1) Or IsNull(Me.txt2) Then
Me.AllowAdditions = False
End If
 
J

John Spencer

Try adding code to the form's Before update event

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.Txt1) Or IsNull(Me.Txt2) Then
MsgBox "Values are required for Txt1 and Txt2. Press Escape twice to
undo changes to this record"
Cancel = True
End If
End Sub


--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 

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