HDI? Suppress Save dialog when closing a created form

  • Thread starter Thread starter Eric
  • Start date Start date
E

Eric

Hello,

I have some code that creates new forms using 'Set <name>
= CreateForm'. I can add a control to the form that
uses 'DoCmd.Close acForm, "name", acSaveNo' to close the
form without the dialog box. Is there a way that I can do
this by using the Close button provided on the form?

Right now if I enable the button I get a dialog box
saying "Do you want to save changes to the design of form
<name>?"

I'd like to use the button, but not have the option of
saving the form. Is there a way to do this?

Thanks
 
Eric said:
Hello,

I have some code that creates new forms using 'Set <name>
= CreateForm'. I can add a control to the form that
uses 'DoCmd.Close acForm, "name", acSaveNo' to close the
form without the dialog box. Is there a way that I can do
this by using the Close button provided on the form?

Right now if I enable the button I get a dialog box
saying "Do you want to save changes to the design of form
<name>?"

I'd like to use the button, but not have the option of
saving the form. Is there a way to do this?

Can you simply save the form explicitly, using

DoCmd.Save acForm, <formname>

before switching the form from design view to form view?
 
Hi Dirk,

Yes, I can save it explicitly and avoid the Save call, but that is what I'm wanting to avoid. I'm creating temporary forms that have different controls schemes on them depending on what information is supplied to create it. Being temporary forms, I don't want them to save at all.

I can do this with a control inside the Detail section. But, the Close button is nicely available and familiar to people who use Windows so I'm interested to know if can be used in a modified way.

Thanks!
 
Eric said:
Yes, I can save it explicitly and avoid the Save call, but that is
what I'm wanting to avoid. I'm creating temporary forms that have
different controls schemes on them depending on what information is
supplied to create it. Being temporary forms, I don't want them to
save at all.

Oh, I see. I misinterpreted your original question, thinking that you
wanted to close and save the form. I have a feeling you're not going to
be able to suppress that message and discard the form, though of course
I could be wrong.

Have you considered taking an alternative approach? Create the
necessary form or forms in advance, and place on them at design time all
the controls you think you might need. Then, when you open the form,
use code to hide those controls that aren't needed this time, move
others around as desired, and size the form appropriately. These
changes, made at run time, will not stick and won't cause the "Save
Changes?" prompt to be generated.
 
Hi Dirk,

Sorry for the long delay. I've thought of that, but didn't
want to do it for this particular project because I'm
making new forms that have controls based on previous
forms made by individual user preferences (whew). I let
them decide how they wanted to label controls and what the
controls actually showed (some wanted the data as is and
some wanted to see the data as graphical attributes to
something else).

That was a wonderful mistake in hindsight. Since the
combinations of control numbers, captions, and types are
up to people I don't have control over, I took the
approach of making a 'wizard' to decide what the temporary
forms should look like based on a combination of the
existing form and some new input from me to make something
else for a temporary use. Temporary forms keep me from
having unknown forms all over the place. I also don't have
to worry about whether my master form has all the things
on Ed's form or Chris's form...

Anyway :), I found this article in the Knowledge Base
http://support.microsoft.com/default.aspx?scid=kb;en-
us;300688 (Microsoft Knowledge Base Article - 300688)

and that's as close as I got. I've gone ahead and just
disabled the close button property and made a button in
the form detail. It was a good try though

Thanks for your help!
 
Back
Top