Event Procedure Issue

  • Thread starter Thread starter heathereandrews
  • Start date Start date
H

heathereandrews

I have two fields that need to be validated on the form, check # an
registration type. It it is a check the user adds a check # and th
registration type is 'C' if it is a deposit it defaults to 0 and th
registration type is 'D'

I have created two event procedures, one before update and the othe
on exit. The first to verify that the check numbers are no
duplicate if not equal to 0 and the second if 0 change the registr
type automatically to D and if >0 change it to C

Here is the problem I am having. If the user wants to go back an
update a row in the form when they try to either 1 change the 0 to
check number or vice versa it yells that is is a duplicate. Prior t
adding that check number validation if you just go up to check it fro
a 0 to check number or vice versa the registration type would no
change.

The event procedures only work on the row I am currently working on.
How can I fix this so they will work on all the rows
 
The question isn't all that clear, but it appears that you want to do some
sort of validation to prevent duplicates. One way would be to index the
field (Yes - No Duplicates)....if the same check # should never exist in the
table. However, that may not be practical if these are checks you are
depositing vs writing from your account....since there is a good chance that
2 or more customers may give you a check with the same number.

It appears you're doing some validation through code to check for
duplicates, but may not have asked the right question. Assuming your table
has a unique ID field named ID, a CustomerID field, and a field named
CheckNum...

varResult = DLookup("CheckNum","SomeTable","ID<>" & Me.ID & " AND
CustomerID=" & Me.CustomerID & " AND CheckNum=" & Me.CheckNum)

If IsNull(varResult)=False then
err.Raise vbobjecterror+1000, "Duplicate Check", "You're entering a
duplicate check!"
End If

So, we're excluding the current row, and checking for a matching check num
from the same customer. I'm not sure if this is what you're trying to do,
but post again with clarification if not.
 
Hi

Thanks for the help. I am doing fine with validating the data. M
issue is, in a form it only validates the line that the user i
initially inputing on. If I go to correct a line that I ha
previously input the validation does not seem to work.

Does that make more sense

Thanks
Heathe
 
What event are you using to run your validation code? You should be using
BeforeUpdate...it sounds like you're not.
 
Back
Top