Hi Guy's, this should be a simple answer that for some reason I can't think why this doesn't work properly!!!!
I may have 12 records that is DelNo 1
This event is After Update on DelNo, so only on the 1st instance it needs to add to tblJobSheets2 1 x record
Name-Town-PostCode 12 Items
Once you change the next DelNo (2 of 12), im trying to stop it adding because the record now exists
It is adding 12 records instead so i believe the If Not Is NUll is not doing it's job
I haven't put full code on as the result is correct just adding however many records that are for the selected DelNo instead of 1 record only
Any advise is appreciated, its probably so simple and jut me having a logic lapse
Code:
If Not IsNull(DLookup("DelNo", "tblJobSheets2", "[Vehicle] = '" & strVehicle & "' And [DelDate] = #" & dtDelDate & "# And [DelNo] = " & intDelNo)) Then DoCmd.CancelEvent
Else
With rs2
.AddNew
!IDNumber = iJS
!DelDate = dtDelDate
!Driver = strDriver
!Vehicle = strVehicle
!DelNo = intDelNo
!DelTo = Me.DelTo & "-" & Me.Town & "-" & Me.PostCode
!Items = strAddDel
!EntCode = strEntCode
!ExtCode = strExtCode
.Update
.Close
End With
End If