How to prevent forms saving empty record lines

Kristaline

New member
Local time
Today, 04:59
Joined
Mar 31, 2009
Messages
8
Hi,

Doesn anyone know how to handle the problems of saving empty form record lines into tables. Also, I need the error message to inform user to input missing data or do not save at all if it is empty?

Thanks in advance.
 
Where are these "empty" records coming from? If you're not entering data into the record, either manually or thru code, Access won't save it.

As to the validation code, here's an example for a single field:

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
  If IsNull(Me.ControlName) Then
    Resp = MsgBox("This Record Cannot Be Saved Without Data in the ControlName Field! Hit 'Yes' to enter this Data or 'No' To Dump This Record.", vbQuestion + vbYesNo + vbDefaultButton1, "Save Changes to Record ???")
    If Resp = vbYes Then
     Cancel = True
     ControlName.SetFocus
    Else
     Me.Undo
    End If
   End If
End If
End Sub
 
Last edited:

Users who are viewing this thread

Back
Top Bottom