Duplicate selections

jon jomaco

Registered User.
Local time
Today, 21:31
Joined
May 20, 2005
Messages
41
Hi. New to this forum but i searched and found a section of code, shown below:

Code:
If Me.Dirty Then
Me.Undo
MsgBox "This would create duplicate references to products for this order. Your changes have been undone.", vbOKOnly + vbInformation, "Changes Erased"
End If

So, I have a form whereby you can select products by selecting them from a dropdown box. If an order allready has a product assigned to it then when this product with a particular productID is selected the message box should be displayed. However no matter what product is selected, whether is it allready assigned to the order or not the message is displayed and i cannot understand why. It did initially work so maybe i should just re-create the form but perhaps there is something missing?

Any info. appreciated, if you need more details or this makes no sense please say.

Thanks,
Jon.
 
You did not say in what event you put the code. As written, it will work just as you described. You are going to need some method (DLookup or DCount maybe) to check for the duplicate rather than just checking for a Dirty record.
 
Thanks for your advice, i realise now that me.dirty does not do what i thought it would and so have used a query instead so that records which have allready been selected and not displayed in the drop down box.

Thanks,

Jon.
 

Users who are viewing this thread

Back
Top Bottom