D
Datacruz via AccessMonster.com
I have a sub form that has "Enddate" and 5 Boolean option 1 through 5 named
"Account numbers". I want to prevent duplicates by date and option accounts
but also restrict entries from being entered. Case in point if I enter
"Enddate" and option 1 I can not enter date and option 3 or 4. I have
reviewed all help files and sort of understand the following code. What would
I do to modify it to meet the requirements?
Private Sub ID_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
If IsNull(Me.ID) OR (Me.ID = Me.ID.OldValue) Then
'Do nothing: it's not a duplicate of itself.
Else
If Not IsNull(DLookup("ID", "Table1", "ID = " & Me.ID)) Then
Cancel = True
strMsg = "You already have that value." & vbCrLf & _
"Enter another value, or press Esc to undo."
MsgBox strMsg, vbExclamation, "Duplicate value!"
End If
End If
End Sub
"Account numbers". I want to prevent duplicates by date and option accounts
but also restrict entries from being entered. Case in point if I enter
"Enddate" and option 1 I can not enter date and option 3 or 4. I have
reviewed all help files and sort of understand the following code. What would
I do to modify it to meet the requirements?
Private Sub ID_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
If IsNull(Me.ID) OR (Me.ID = Me.ID.OldValue) Then
'Do nothing: it's not a duplicate of itself.
Else
If Not IsNull(DLookup("ID", "Table1", "ID = " & Me.ID)) Then
Cancel = True
strMsg = "You already have that value." & vbCrLf & _
"Enter another value, or press Esc to undo."
MsgBox strMsg, vbExclamation, "Duplicate value!"
End If
End If
End Sub