S
SW
Hello,
I have a subform that displays records in a table (ParentBookID), in
Datasheet view.
User can edit/add records directly in the subform.
I want to make sure user doesn't enter a duplicate record.
So in the subform's AfterUpdate event, I have the below code:
-------------------------------------------------------
Private Sub Form_AfterUpdate()
Dim db As Database
Dim aSQL As String
Dim aRST As Recordset
Set db = CurrentDb
aSQL = "SELECT First(ParentBookID.ParentBookID) AS [ParentBookID Field] " _
& "FROM ParentBookID " _
& "GROUP BY ParentBookID.ParentBookID " _
& "HAVING (((Count(ParentBookID.ParentBookID))>1));"
Set aRST = db.OpenRecordset(aSQL, dbOpenDynaset)
If aRST.RecordCount > 0 Then
MsgBox "DUPLICATE ENTRY!"
End If
End Sub
-------------------------------------------------------
The code is running fine, able to give the message. But after the message,
I want the duplicated entry the user just added in the subform be selected.
How can I do that?
THANKS!
I have a subform that displays records in a table (ParentBookID), in
Datasheet view.
User can edit/add records directly in the subform.
I want to make sure user doesn't enter a duplicate record.
So in the subform's AfterUpdate event, I have the below code:
-------------------------------------------------------
Private Sub Form_AfterUpdate()
Dim db As Database
Dim aSQL As String
Dim aRST As Recordset
Set db = CurrentDb
aSQL = "SELECT First(ParentBookID.ParentBookID) AS [ParentBookID Field] " _
& "FROM ParentBookID " _
& "GROUP BY ParentBookID.ParentBookID " _
& "HAVING (((Count(ParentBookID.ParentBookID))>1));"
Set aRST = db.OpenRecordset(aSQL, dbOpenDynaset)
If aRST.RecordCount > 0 Then
MsgBox "DUPLICATE ENTRY!"
End If
End Sub
-------------------------------------------------------
The code is running fine, able to give the message. But after the message,
I want the duplicated entry the user just added in the subform be selected.
How can I do that?
THANKS!