Field Required from other field.

outlaw318

Registered User.
Local time
Today, 09:34
Joined
Oct 2, 2003
Messages
15
Wasnt sure were to put this, but here it goes. I have and two fields in my requisition table. One is EmergencyDate and the other is EmergencyUse. If EmergencyDate is filled in the EmergencyUse would be required. I searched the boards, but I guess I didnt know how to search it. Any suggestions?
 
Go into design view for the table, and set the field as REQUIRED = YES and the database will not save the record unless it is filled out.
 
The field is only going to be required based upon another field. If someone puts in the emergency date then they must fill out the emergency use.
 
Jet does not support triggers so you can only do this with form events. Add your edit to the FORM's BeforeUpdate event. If the EmergencyDate is filled in then cancel the update if the EmergencyUse is not.

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsDate(Me.EmergencyDate) Then
    If Len(Trim(Me.EmergencyUse)) = 0 Then
        Me.EmergencyUse.SetFocus
        MsgBox "Emergency Use is required, update not completed", vbOkOnly
        Cancel = True
    End If
End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom