By adding an unit number A1 and an OUT date in the form, i want to get a message that an error/popup message that its already OUT (and so cant be added in the table). (Because unitnumber A1 is already in the table as A1 with an OUT date)
Table name: Units
Form name: Units
field1 = Unit_name
field2= In_date
field3= Out_date
field4 = Project_name
This is what I have so far:
Code:
Private Sub Unit_name_BeforeUpdate(Cancel As Integer)
DLookUp("Units", "[Unit_name]= " & [Unit_name] & " And [Date_out]= '" & [Date_out] & "'")
MsgBox "Name Is Already In Database!"
End If
End Sub