linked fields

  • Thread starter Thread starter cecild
  • Start date Start date
C

cecild

I have a form entering into a linked dbf table. How can I require fields in
the form since I don't have the ability to do it in the table. Thanks,
 
You can use the BeforeUpdate event of the form to check that the control(s)
bound to the required field(s) is not null, and cancel the update if it is.
Something like:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(txtMyRequiredField) Then
Cancel = True
MsgBox "My Required Field must contain data"
txtMyRequiredField.SetFocus
Exit Sub 'can omit this if only checking one field; it prevents all
the message boxes appearing one after the other if more than one required
field is missing
End If
'repeat for each required field
End Sub

HTH,

Rob
 
Back
Top