Force Users to Update the Required Fields Before Saving Record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form with the following fields: Job Number, Job Description,
Assigned to, Tasks, Cost and Completion Date. I want to required user who
make change to the Tasks field, also update the Cost and Completion Date
fields, otherwise they get a warning/error message and can't save the record.
Is there any way to do it?

Thanks,
Mike
 
If you want to prevent the user from saving a record if these fields are
blank, open your table in design view, and in the lower pane set the
Required property to Yes for each field.

If you want to give a warning message but allow them to save anyway, use the
BeforeUpdate event procedure of the form:

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

If IsNull(Me.[Job Description] Then
strMsg = strMsg & "Blank job description" & vbcrlf
End If

If IsNull(Me.[Assigned to] Then
strMsg = strMsg & "Assigned to is blank." & vbcrlf
End If

'and so on

If Len(strMsg) > 0 Then
strMsg = strMsg & vbCrLf & "Continue anyway?"
If MsgBox strMsg, vbYesNo + vbDefaultButton2 <> vbYes Then
Cancel = True
'Me.Undo
End If
End If
End Sub
 
Back
Top