form validation

  • Thread starter Thread starter tom
  • Start date Start date
T

tom

Hi I would like to ensure all fields on the form are
filled before a user exits the db. I have a quit button
on my form and it is there for people to exit entirely
from access. I need to validate the form and display a
message if not all fields are filled. This way i will
safeguard against any bad records.

how do i look through all the records to display a
message and wait til they follow a procedure before
exiting?
 
Do you really want a value in ALL fields? What happens when the user
doesn't know or there is suitable answer? If you really do, you can set the
"Required " property to Yes at the table level.
To control form level entry, you could use code at the Before Update event
to check each control for non-null, before executing the Close command.

like:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me!my1stControl) or Me!my1stControl = "" Then
Msgbox " Must have an entry here."
Me!my1stControl.SetFocus
EsleIf IsNull(Me!my2ndControl) or Me!my2ndControl = "" Then
Msgbox " Must have an entry here."
Me!my2ndControl.SetFocus
' etc.
Else
DoCmd.Close
End If
End Sub

-Ed
 
Back
Top