Prev: skuska
Next: asun jimeno@gmail.com
From: deb on 30 Mar 2010 11:13 access 2003 mainform is f001Projectreview with subform f015KeyMilestones(PK ProjectID) I have the below code in the subforms beforeUpdate event. It is to prevent duplicates, however, when I try to edit the ActualDt in the record it recognizes the record as a duplicate. How can I make changes in the record without it thinking it is a dupe? If ((Me.KeyMilestonesSubID) = 12 Or (Me.KeyMilestonesSubID) = 20) Then strWhere = "([ProjectID] = " & Nz(Me.ProjectID, 0) & _ ") AND ([KeyMilestonesSubID] = " & Nz(Me.KeyMilestonesSubID, 0) & ")" varResult = DLookup("[KeyMilestonesID]", "[t51KeyMilestones]", strWhere) If Not IsNull(varResult) Then MsgBox "Duplicate Entry." & vbCrLf & vbCrLf & _ "There can only be one PM080 and PM670 per project.", vbExclamation, "Duplicate entry" Cancel = True End If Exit Sub End If -- deb
From: Daryl S on 31 Mar 2010 09:24 Deb - You want to look for 2 or more records already in the table (not including the one you are working on). Try this (untested): If ((Me.KeyMilestonesSubID) = 12 Or (Me.KeyMilestonesSubID) = 20) Then strWhere = "([ProjectID] = " & Nz(Me.ProjectID, 0) & _ ") AND ([KeyMilestonesSubID] <> " & Nz(Me.KeyMilestonesSubID, 0) & _ ") AND ([KeyMilestonesSubID] in (12,20))" varResult = DLookup("[KeyMilestonesID]", "[t51KeyMilestones]", strWhere) If varResult >= 2 Then MsgBox "Duplicate Entry." & vbCrLf & vbCrLf & _ "There can only be one PM080 and PM670 per project.", vbExclamation, "Duplicate entry" Cancel = True End If Exit Sub End If -- Daryl S "deb" wrote: > access 2003 > mainform is f001Projectreview with subform f015KeyMilestones(PK ProjectID) > > I have the below code in the subforms beforeUpdate event. > It is to prevent duplicates, however, when I try to edit the ActualDt in the > record it recognizes the record as a duplicate. > How can I make changes in the record without it thinking it is a dupe? > > If ((Me.KeyMilestonesSubID) = 12 Or (Me.KeyMilestonesSubID) = 20) Then > strWhere = "([ProjectID] = " & Nz(Me.ProjectID, 0) & _ > ") AND ([KeyMilestonesSubID] = " & Nz(Me.KeyMilestonesSubID, 0) > & ")" > varResult = DLookup("[KeyMilestonesID]", "[t51KeyMilestones]", > strWhere) > If Not IsNull(varResult) Then > MsgBox "Duplicate Entry." & vbCrLf & vbCrLf & _ > "There can only be one PM080 and PM670 per project.", vbExclamation, > "Duplicate entry" > Cancel = True > End If > Exit Sub > End If > -- > deb
From: Risse on 2 Apr 2010 02:44 "Daryl S" <DarylS(a)discussions.microsoft.com> kirjoitti viestiss�:A51133CC-75D2-40A7-9B64-8605433A3E17(a)microsoft.com... > Deb - > > You want to look for 2 or more records already in the table (not including > the one you are working on). Try this (untested): > > If ((Me.KeyMilestonesSubID) = 12 Or (Me.KeyMilestonesSubID) = 20) Then > strWhere = "([ProjectID] = " & Nz(Me.ProjectID, 0) & _ > ") AND ([KeyMilestonesSubID] <> " & Nz(Me.KeyMilestonesSubID, 0) & _ > ") AND ([KeyMilestonesSubID] in (12,20))" > varResult = DLookup("[KeyMilestonesID]", "[t51KeyMilestones]", > strWhere) > If varResult >= 2 Then > MsgBox "Duplicate Entry." & vbCrLf & vbCrLf & _ > "There can only be one PM080 and PM670 per project.", > vbExclamation, "Duplicate entry" > Cancel = True > End If > Exit Sub > End If > > -- > Daryl S > > > "deb" wrote: > >> access 2003 >> mainform is f001Projectreview with subform f015KeyMilestones(PK >> ProjectID) >> >> I have the below code in the subforms beforeUpdate event. >> It is to prevent duplicates, however, when I try to edit the ActualDt in >> the >> record it recognizes the record as a duplicate. >> How can I make changes in the record without it thinking it is a dupe? >> >> If ((Me.KeyMilestonesSubID) = 12 Or (Me.KeyMilestonesSubID) = 20) >> Then >> strWhere = "([ProjectID] = " & Nz(Me.ProjectID, 0) & _ >> ") AND ([KeyMilestonesSubID] = " & Nz(Me.KeyMilestonesSubID, >> 0) >> & ")" >> varResult = DLookup("[KeyMilestonesID]", >> "[t51KeyMilestones]", >> strWhere) >> If Not IsNull(varResult) Then >> MsgBox "Duplicate Entry." & vbCrLf & vbCrLf & _ >> "There can only be one PM080 and PM670 per project.", >> vbExclamation, >> "Duplicate entry" >> Cancel = True >> End If >> Exit Sub >> End If >> -- >> deb
|
Pages: 1 Prev: skuska Next: asun jimeno@gmail.com |