Validation Rule on form

E

edw12

Hi. I used a variation of this code on a form that I am creating, in order to check for duplicates on entry. However, Access keeps the error in place, even after the duplicate has been removed.

For example, Item# 08-12 has already been used. If I enter this Item# again, a popup displays saying "This Item# has already been used. Do you want to use it again?" with a yes or no option.

This part works great, but if I select No, and change the Item#, the same error message pops up with the entered text, even if that Item# has not been used before.

Is there a way to reset this code, after it has run once?

I am fairly new to Access, and I greatly appreciate any help!

EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com/default.aspx?ref=ng
 
P

Piet Linden

It should be in the BeforeInsert event of your form. Then you can
cancel the insert or respond accordingly.
 
S

Steve Sanford

I couldn't find the code you referenced, but in Access help, look at the "Err
Object".

"The Err object's properties are reset to zero or zero-length strings ("")
after an Exit Sub, Exit Function, Exit Property or Resume Next statement
within an error-handling routine. Using any form of the Resume statement
outside of an error-handling routine will not reset the Err object's
properties. The Clear method can be used to explicitly reset Err."
(Err.Clear)

The Err object is an intrinsic object with global scope. There is no need to
create an instance of it in your code.


HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top