A
Al Camp
Hmmm... I sent this out over an hour ago and it still hasn't shown up.
Pardon the resend...
I'm trying to prevent duplicate entries in a field of a continuous
subform (frmScheduledEvents).
The Main form, frmConferences, defines a Conference via a ConferenceID
(Long), and the
subform lists Events (the MANY) at that conference linked via ConferenceID.
Each
event has an EventNo identifier (Text) such as A-12, B-6, D-11, etc... and
the Main and Sub are linked via ConferenceID (w/RefIntegrity)
Conference 12 and Conference 13 can each have an A-1 Event... but no
"individual" conference can have two A-1 entries.
So, I can't set the EventNo field to NoDupes... I'll have to check each
time an EventNo is entered in the subform.
OK, so I coded this up...
Private Sub EventNo_BeforeUpdate(Cancel As Integer)
If IsNull(DLookup("[EventNo]", "tblScheduledEvents", "EventNo= " &
Me.EventNo & " and ConferenceID = " & Me.ConferenceID)) Then
Exit Sub
Else
MsgBox "Duplicate EventNo " & EventNo & vbCrLf & "Please correct
entry...", vbOKOnly, "Duplicate Value"
Cancel = True
EventNo.Undo
End If
End Sub
Problem: My code throws a "Run Time Error 2001" "You Cancelled the
Previous Operation." And... the Help button associated with the error just
brings up a blank Help screen!
EventNo has no other code,
Hope this isn't a "can't see the forest for the trees", but I can't see
anything wrong with my code/syntax.
Thanks in advance,
Al Camp
Pardon the resend...
I'm trying to prevent duplicate entries in a field of a continuous
subform (frmScheduledEvents).
The Main form, frmConferences, defines a Conference via a ConferenceID
(Long), and the
subform lists Events (the MANY) at that conference linked via ConferenceID.
Each
event has an EventNo identifier (Text) such as A-12, B-6, D-11, etc... and
the Main and Sub are linked via ConferenceID (w/RefIntegrity)
Conference 12 and Conference 13 can each have an A-1 Event... but no
"individual" conference can have two A-1 entries.
So, I can't set the EventNo field to NoDupes... I'll have to check each
time an EventNo is entered in the subform.
OK, so I coded this up...
Private Sub EventNo_BeforeUpdate(Cancel As Integer)
If IsNull(DLookup("[EventNo]", "tblScheduledEvents", "EventNo= " &
Me.EventNo & " and ConferenceID = " & Me.ConferenceID)) Then
Exit Sub
Else
MsgBox "Duplicate EventNo " & EventNo & vbCrLf & "Please correct
entry...", vbOKOnly, "Duplicate Value"
Cancel = True
EventNo.Undo
End If
End Sub
Problem: My code throws a "Run Time Error 2001" "You Cancelled the
Previous Operation." And... the Help button associated with the error just
brings up a blank Help screen!
EventNo has no other code,
Hope this isn't a "can't see the forest for the trees", but I can't see
anything wrong with my code/syntax.
Thanks in advance,
Al Camp