Thanks. I attached my easy form and 2 unitnumbers database.
Im quite a newbee, started Access this week. Could you help me out? So prevent adding a movement of unitnumber H0168 with an IN date. Adding an out date should be working.
Database11.accdb
The VBA I use in Excel is the following regarding data validation: (Column A = unit number, B = In date, C = Out date, D = start Date, F = Project number)
Code:
Dim cell As Range, bErr As Boolean
For Each cell In ActiveSheet.UsedRange.Columns("B").Cells
If Not cell.Validation.Value Then
bErr = True
MsgBox cell.Address(False, False) & " Unit is al in!"
cell.Select
Range("a:i").End(xlDown).Select
Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).EntireRow.Delete
End If
Next
For Each cell In ActiveSheet.UsedRange.Columns("A").Cells
If Not cell.Validation.Value Then
bErr = True
MsgBox cell.Address(False, False) & " Unit bestaat niet!"
cell.Select
Range("a:i").End(xlDown).Select
Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).EntireRow.Delete
End If
Next
For Each cell In ActiveSheet.UsedRange.Columns("C").Cells
If Not cell.Validation.Value Then
bErr = True
MsgBox cell.Address(False, False) & " Unit is al uit!"
cell.Select
Range("a:i").End(xlDown).Select
Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).EntireRow.Delete
End If
Next
For Each cell In ActiveSheet.UsedRange.Columns("F").Cells
If Not cell.Validation.Value Then
bErr = True
MsgBox cell.Address(False, False) & " Verkeerd project!"
cell.Select
Range("a:i").End(xlDown).Select
Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).EntireRow.Delete
End If
Next
If Not bErr Then MsgBox "Unit toevoeging succesvol!"
End Sub