D
deb
access 2003
Main form is called f018ContrPerfEmissGua has the fields UnitNo(number) and
ckGEN(yes/No ckbox)
subform is called f018ContrPerfEmissGuaDetails (linked by ContrPerfEmissGuaID)
User will select the unitNo, and check ckGEN(if it is a GEN) from the main
form
When the user tries to enter data into the subform and it already has a
record with the same unitNo and ckGEN values then undo the current record,
display msg and move to original record.
I tried, but cannot figure it out. see below
On the subform - before update I tried...
I think the stLinkCriteria and dcount are wrong.
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim UID As String
Dim GID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
UID = Me.parent.UnitNo.Value
GID = Me.parent.ckGEN.Value
stLinkCriteria = "f018ContrPerfEmissGua.UnitNo=" & UID & " and
f018ContrPerfEmissGua.ckGEN= " & GID
'Check t81ContrPerfEmissGuaDetails table for duplicate UnitID(number)
and ckGEN(yes/no)
If DCount("me.parent.UnitNo", " & me.parent.ckGEN"
"t81ContrPerfEmissGuaDetails", _
stLinkCriteria) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "Warning Unit or Unit Gen " _
& UID & " has already been entered." _
& vbCr & vbCr & "You will now been taken to the record.", _
vbInformation, "Duplicate Information"
'Go to record of original record
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub
Thanks in advance!!!
Main form is called f018ContrPerfEmissGua has the fields UnitNo(number) and
ckGEN(yes/No ckbox)
subform is called f018ContrPerfEmissGuaDetails (linked by ContrPerfEmissGuaID)
User will select the unitNo, and check ckGEN(if it is a GEN) from the main
form
When the user tries to enter data into the subform and it already has a
record with the same unitNo and ckGEN values then undo the current record,
display msg and move to original record.
I tried, but cannot figure it out. see below
On the subform - before update I tried...
I think the stLinkCriteria and dcount are wrong.
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim UID As String
Dim GID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
UID = Me.parent.UnitNo.Value
GID = Me.parent.ckGEN.Value
stLinkCriteria = "f018ContrPerfEmissGua.UnitNo=" & UID & " and
f018ContrPerfEmissGua.ckGEN= " & GID
'Check t81ContrPerfEmissGuaDetails table for duplicate UnitID(number)
and ckGEN(yes/no)
If DCount("me.parent.UnitNo", " & me.parent.ckGEN"
"t81ContrPerfEmissGuaDetails", _
stLinkCriteria) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "Warning Unit or Unit Gen " _
& UID & " has already been entered." _
& vbCr & vbCr & "You will now been taken to the record.", _
vbInformation, "Duplicate Information"
'Go to record of original record
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub
Thanks in advance!!!