Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking fields on a form before processing

Status
Not open for further replies.

mzh1605

IS-IT--Management
Oct 19, 2009
1
AU
Hi All

I am trying to check that all fields on a form are completed before allowing further processing to take place. I am using the code below but it is not working (doesn't seem to be reading the data from the form at all).

Private Sub Close_Click()
Dim rst As DAO.Recordset, intI, ErrCount As Integer
Dim FldName As String
Dim fld As Field
Set rst = Me.Recordset
ErrCount = 0
For Each fld In rst.Fields
' Check field values.
If IsNull(fld) Then
ErrCount = ErrCount + 1
FldName = fld.Name
MsgBox (FldName & " not entered. Please update " & FldName & ".")
Exit For
End If
Next
If ErrCount = 0 Then
DoCmd.Close acForm, "frmSTPCheck", acSaveYes
Call RepDataAdd
End If
End Sub

Please help a novice who is in over his head.

Thanks
 
Use the BeforeUpdate event procedure.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 

That's the Form_BeforeUpdate event.

Also, replace you line

Exit For

with

Cancel = True


The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top