Closing Form control vs Button control for Exiting 
Author Message
 Closing Form control vs Button control for Exiting

I have two problems.  

First, I want to put a vbYesNoCancel box up when folks try exiting (save
changes, abandon changes or return to form).  The problem is when I put the
code in at the Form BeforeUpdate level, the Form BeforeUpdate has priority
over the other field controls which have BeforeUpdate logic.  (i.e. when I
try executing my "Save" button which has BeforeUpdate logic, the logic is
never reached because the Form BeforeUpdate is executed first)  What is the
best method for accomplishing priority on this -- I want the "X" close to run
only when someone tries closing the form/window/popup?

The second problem has to do with the logic on the "Save" option.  Below is
my logic, but I get an error from the system when I execute the logic:

    If iQuit = vbYes Then
      DoCmd.RunCommand acCmdSaveRecord
      DoCmd.Close
    End If

Error:
Run-time error '2115'
The macro of function set to the BeforeUpdate or ValidationRule property for
this field ispreventing Microsoft Office from saving data in the field.

I'm new at all of this so please bear with any ignorance I may have.

Cheers,
Leslie



Tue, 18 Dec 2007 01:00:03 GMT  
 Closing Form control vs Button control for Exiting
For the second problem - DoCmd.RunCommand acCmdSaveRecord use Dirty = False
instead.
THT
Bill

Quote:
> I have two problems.

> First, I want to put a vbYesNoCancel box up when folks try exiting (save
> changes, abandon changes or return to form).  The problem is when I put
the
> code in at the Form BeforeUpdate level, the Form BeforeUpdate has priority
> over the other field controls which have BeforeUpdate logic.  (i.e. when I
> try executing my "Save" button which has BeforeUpdate logic, the logic is
> never reached because the Form BeforeUpdate is executed first)  What is
the
> best method for accomplishing priority on this -- I want the "X" close to
run
> only when someone tries closing the form/window/popup?

> The second problem has to do with the logic on the "Save" option.  Below
is
> my logic, but I get an error from the system when I execute the logic:

>     If iQuit = vbYes Then
>       DoCmd.RunCommand acCmdSaveRecord
>       DoCmd.Close
>     End If

> Error:
> Run-time error '2115'
> The macro of function set to the BeforeUpdate or ValidationRule property
for
> this field ispreventing Microsoft Office from saving data in the field.

> I'm new at all of this so please bear with any ignorance I may have.

> Cheers,
> Leslie



Wed, 19 Dec 2007 01:47:45 GMT  
 Closing Form control vs Button control for Exiting
Thanks Bill!

Do I put the "Dirty = False" before or after the "DoCmd.RunCommand
acCmdSaveRecord " command?

In my first part of the question, even if I can do some kind of check on
using the Windows 'X" (upper RH corner) to isolate that functionality would
be great.

Thanks again Bill for your help!

Cheers,
Leslie

Quote:

> I have two problems.  

> First, I want to put a vbYesNoCancel box up when folks try exiting (save
> changes, abandon changes or return to form).  The problem is when I put the
> code in at the Form BeforeUpdate level, the Form BeforeUpdate has priority
> over the other field controls which have BeforeUpdate logic.  (i.e. when I
> try executing my "Save" button which has BeforeUpdate logic, the logic is
> never reached because the Form BeforeUpdate is executed first)  What is the
> best method for accomplishing priority on this -- I want the "X" close to run
> only when someone tries closing the form/window/popup?

> The second problem has to do with the logic on the "Save" option.  Below is
> my logic, but I get an error from the system when I execute the logic:

>     If iQuit = vbYes Then
>       DoCmd.RunCommand acCmdSaveRecord
>       DoCmd.Close
>     End If

> Error:
> Run-time error '2115'
> The macro of function set to the BeforeUpdate or ValidationRule property for
> this field ispreventing Microsoft Office from saving data in the field.

> I'm new at all of this so please bear with any ignorance I may have.

> Cheers,
> Leslie



Wed, 19 Dec 2007 04:24:02 GMT  
 Closing Form control vs Button control for Exiting
Instead of.
HTH

Quote:
> Thanks Bill!

> Do I put the "Dirty = False" before or after the "DoCmd.RunCommand
> acCmdSaveRecord " command?

> In my first part of the question, even if I can do some kind of check on
> using the Windows 'X" (upper RH corner) to isolate that functionality
would
> be great.

> Thanks again Bill for your help!

> Cheers,
> Leslie


> > I have two problems.

> > First, I want to put a vbYesNoCancel box up when folks try exiting (save
> > changes, abandon changes or return to form).  The problem is when I put
the
> > code in at the Form BeforeUpdate level, the Form BeforeUpdate has
priority
> > over the other field controls which have BeforeUpdate logic.  (i.e. when
I
> > try executing my "Save" button which has BeforeUpdate logic, the logic
is
> > never reached because the Form BeforeUpdate is executed first)  What is
the
> > best method for accomplishing priority on this -- I want the "X" close
to run
> > only when someone tries closing the form/window/popup?

> > The second problem has to do with the logic on the "Save" option.  Below
is
> > my logic, but I get an error from the system when I execute the logic:

> >     If iQuit = vbYes Then
> >       DoCmd.RunCommand acCmdSaveRecord
> >       DoCmd.Close
> >     End If

> > Error:
> > Run-time error '2115'
> > The macro of function set to the BeforeUpdate or ValidationRule property
for
> > this field ispreventing Microsoft Office from saving data in the field.

> > I'm new at all of this so please bear with any ignorance I may have.

> > Cheers,
> > Leslie



Wed, 19 Dec 2007 05:20:40 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Problem with Controlled Closing of a Form when exiting throught the Window-Close-Button

2. Forms button vs controls Toolbox command button

3. Exit Control and close form

4. Control Exit event kills Button Click Event in Access2002 Forms

5. ActiveX controls vs Forms controls

6. ActiveX Controls vs Forms Controls

7. Limit a control based on a closed form's control

8. Controlling the Close Button on a Form

9. Controlling the Close Button on a Form

10. Form Close Vs Close Window button problem


 
Powered by phpBB® Forum Software © phpBB Group