Adding Records :: Conditional

  • Thread starter Thread starter Josef
  • Start date Start date
J

Josef

how do i stop a user from adding a new record is the current record is
not completetly filled?

it seems like a simple solution ... getting a brain freeze from it tho !

thx
 
To insist the the record can never be saved if a field is blank:
1. Open your table in design view.

2. Select the field that must be entered.

3. In the lower pane, set the Required property to Yes.

4. Repeat for other required fields.

5. Save changes to the table.


To warn the user when a field is blank, but let them save it anyway, use the
BeforeUpdate event procedure of the *form*.

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
Dim bWarn As Boolean

If IsNull(Me.[SomeField]) Then
bWarn = True
strMsg = strMsg & "SomeField is blank." & vbCrLf
End If
If IsNull(Me.[AnotherField]) Then
bWarn = True
strMsg = strMsg & "AnotherField is blank." & vbCrLf
End If
'and so on.

If bWarn Then
strMsg = strMsg & vbCrLf & "Continue anyway?"
If MsgBox(strMsg, vbYesNo+vbDefaultButton2, "Incomplete") <> vbYes
Then
Cancel = True
MsgBox "Enter the data, or press <Esc> to cancel the entry."
End If
End If
End Sub
 
Back
Top