Expand|Select|Wrap|Line Numbers
- varX=dlookup("[ProductID]","ProductsTableName", strCriteria)
- if isnull(varX) then
- 'Proceed to add new record and create new ProductID (autonumber)
- else
- 'Use ProductID currently held in varX
- endif
The 'criteria' is a compound of 9 fields, seven of which are foreign keys populated by selecting from combo-boxes. The other two fields are text selected from combo boxes but not limited to the list. These don't seem to be the cause of the problem i.e. the duplicate records match each other perfectly on the 'criteria' fields. (They would not be duplicates if they were different !!)
With hindsight, I should perhaps have created a unique index on theses nine fields but that seemed rather cumbersome; the code should work; it's desireable but not critical to prevent duplication of products.
I've searched previous postings for a clue as to what is going wrong but most comment is about about finding duplicates and removing them. But why do they occur in the first place?