I
Irshad Alam
I have a form and subform, while posting the data I want a message to prompt
if data is going to duplicate and undo the entry
My Table name for the main form : OsTabA
My table name for the subform : OsTabB
My Query having all the fields from both the above table named : OsQ1
Main Form Name : OsFormA
subForm Name : OsFormB
Field in the subform are as below :
OsEmpName
OsDate
I tried the to use the below code in the Subform Before update event, But it
produces error - Runtime error 3077:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
rs.FindFirst "OsEmpName = '" & [Forms]![OsFormA]![Combo11] & "' And " &
"OsDate = #" & [Forms]![OsFormA]![Text13]
If Not rs.NoMatch Then
MsgBox "The Record will Duplicate, check It !!!"
Cancel = True
End If
End Sub
Please advice the correct the VB code to handle this situation.
Thanks and best regards
Irshad
if data is going to duplicate and undo the entry
My Table name for the main form : OsTabA
My table name for the subform : OsTabB
My Query having all the fields from both the above table named : OsQ1
Main Form Name : OsFormA
subForm Name : OsFormB
Field in the subform are as below :
OsEmpName
OsDate
I tried the to use the below code in the Subform Before update event, But it
produces error - Runtime error 3077:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
rs.FindFirst "OsEmpName = '" & [Forms]![OsFormA]![Combo11] & "' And " &
"OsDate = #" & [Forms]![OsFormA]![Text13]
If Not rs.NoMatch Then
MsgBox "The Record will Duplicate, check It !!!"
Cancel = True
End If
End Sub
Please advice the correct the VB code to handle this situation.
Thanks and best regards
Irshad