Validation Code and Me.dirty

G

Guest

Hello all,

I'm working on a form where I have validation code built into the form level
Before_Update event - it's necessary because of a cross validation. On
failure, I use Cancel = True to cancel the update.

My problem is I also have a close command and the code there sets me.dirty
to false to force a save. That fires the before_update - which results in the
save throwing a 2101 error (I guess I can't force the dirty property to false
if I cancel the update and therefore the save).

For now, I plan to trap the 2101 and ignore it - but I'm uncomfortable that
I could be masking a valid error.

Is there a better way?
 
G

Guest

Hi Rascal,

I use a general form level procedure to validate the data, which sets a
boolean to true or false, I call this procedure before any atempt to close or
save the data can be made (including If Not bAllowClose Then Cancel=-1 in
beforeUpdate), but also surround the Me.Dirty = False with if bAllowClose.
This prevents the error from being raised in the first place.

hope this helps,

TonyT..
 
G

Guest

I like it a lot. Thanks, Tony.


TonyT said:
Hi Rascal,

I use a general form level procedure to validate the data, which sets a
boolean to true or false, I call this procedure before any atempt to close or
save the data can be made (including If Not bAllowClose Then Cancel=-1 in
beforeUpdate), but also surround the Me.Dirty = False with if bAllowClose.
This prevents the error from being raised in the first place.

hope this helps,

TonyT..
 

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

Similar Threads


Top