lookforsmt
Registered User.
- Local time
- Today, 16:06
- Joined
- Dec 26, 2011
- Messages
- 672
HI! all
I am trying to avoid duplicate data entry in two tables.
I have tables called tbl_Incident and tbl_Master
Below is the before update code on field MICR in tbl_Incident
while i try to add the same MICR again in tbl_Incident it popups msg and avoid input, The 1st code is fine,
But if i try adding MICR which is already in tbl_Master, it should popup msg and avoid input. I am not able to write this code. ' Help Required
Thanks
I am trying to avoid duplicate data entry in two tables.
I have tables called tbl_Incident and tbl_Master
Below is the before update code on field MICR in tbl_Incident
Code:
Private Sub MICR_BeforeUpdate(Cancel As Integer)
Dim strMICR As String
strMICR = Me.MICR
If DCount("MICR", "tbl_Incident", strMICR) > 0 Then
'Undo duplicate entry
Me.Undo
'Warning msgbox for duplication
MsgBox "Duplicate MICR in tlb_Incident " & "" _
& vbCr & strMICR, vbInformation _
, " Duplicate MICR"
Exit Sub
Else
End If
If DCount("MICR", "tbl_Master", MICR) > 0 Then ' Help required
'Undo duplicate entry
Me.Undo
'Warning msgbox for duplication
MsgBox "Duplicate MICR in tbl_Master " & "" _
& vbCr & MICR, vbInformation _
, " Duplicate MICR"
End If
End Sub
while i try to add the same MICR again in tbl_Incident it popups msg and avoid input, The 1st code is fine,
But if i try adding MICR which is already in tbl_Master, it should popup msg and avoid input. I am not able to write this code. ' Help Required
Thanks