-
How to Undo an Event?
Is it possible to Undo an Event? say Afterinsert.
Actually I am checking for Duplicate Records in afterinsert of every form.
[vba]
Function Check_Duplicates() As Boolean
Dim tempset As Recordset
Dim resultset As Recordset
Dim filterstring As String
Set tempset = CodeContextObject.Recordset
tempset.MoveLast
For Each Field In tempset.Fields
If Field.OrdinalPosition = 0 Then 'Primary Key
filterstring = Field.Name & "<>" & tempset(Field.OrdinalPosition).Value
Else
Select Case VarType(tempset(Field.OrdinalPosition))
Case 1, 9, 8209 '8209 is OLE
'Skip
Case 3, 6, 11
'As it is
If filterstring = "" Then filterstring = Field.Name & "=" & _
tempset(Field.OrdinalPosition).Value _
Else filterstring = filterstring & " AND " & Field.Name & "=" & _
tempset(Field.OrdinalPosition).Value
Case 7
'Add #
If filterstring = "" Then filterstring = Field.Name & "=#" & _
tempset(Field.OrdinalPosition).Value & "#" _
Else filterstring = filterstring & " AND " & Field.Name & "=#" & _
tempset(Field.OrdinalPosition).Value & "#"
Case 8
'Add quotes
If filterstring = "" Then filterstring = Field.Name & "='" & _
tempset(Field.OrdinalPosition).Value & "'" _
Else filterstring = filterstring & " AND " & Field.Name & "='" & _
tempset(Field.OrdinalPosition).Value & "'"
End Select
End If
Next Field
tempset.Filter = filterstring
Set resultset = tempset.OpenRecordset()
If Not (resultset.BOF And resultset.EOF) Then
'Duplicacy Occurs
'Here I wanna Undo that Event which triggered this code. How?
End If
End Function
[/vba]
How to Retain that record in the post 'Beforeinsert' Stage?
Edited 21-Jul-10 by geekgirlau: Reason: insert vba tags
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules