ADVANCED: Suppressing "Save Layout?" dialog on form close


T

trexx

Hello everyone,

I have a form with a subform in it. The subform has a query as its
source object.

Since the fields inside the query always load with the same width,
either the user or the db has to resize the columns of the query's
datasheet. Regardless whether the user resizes the columns manually or
whether I do it via code, closing the parent form always prompts the
user to save changes to the layout of the subform's query.

Frankly, it's irrelevant whether the changes are saved or not because
the query is rebuilt each time the form is opened. I just want it to
not show the "save layout changes?" dialog. I've Tired the OnClose and
OnUnload events both on the query's datasheet and the form but when the
form is closed (when the user presses the red "X" box on the top right
of the screen), the dialog always appears before the events are
triggered. I've turned off the SetWarnings also without any
difference. Even DoCmd.Close (with the option to prompt set to none)
also triggers AFTER the dialog appears!

If I use the AllowDesignChanges property on the subform's datasheet,
then the columns can't be resized. If I make the subform set its
sourceobject to "" (empty quotation marks) then the dialog doesn't
appear, but the user shouldn't have to do that before closing the form
and I haven't figured out how to do it without having a separate
"close/exit" button to my already crowded form.

All I want is for the user to be able to use the form and then click
the form's red "X" to close the form without the db asking him
anything.

Help...


Juan
 
Ad

Advertisements

N

Nikos Yannacopoulos

Juan,

I disable the form's built-in close button in the control box (the "X")
and add my own Close button, with:

DoCmd.Close acForm, Me.Name, acSaveNo

Hope this works for you.

Nikos
 
G

Guest

Use the acSaveNo option in the Close method. This will close your form
without saving it or prompting the user.

DoCmd.Close acForm, Me.Name, acSaveNo
 
G

Guest

It doesn't do that to me. I don't have A2K+ in front of
me, is there a form property that controls this behaviour?

(david)
 
G

Guest

I misread the original post. I did not remember the part about clicking on
the X to do the close. I can't think of a clever way to control the message
when the X has been clicked.
 
D

david epsom dot com dot au

I have the "Allow Design Changes" property set to
'in design view only'

(david)
 
Ad

Advertisements

D

david epsom dot com dot au

I don't know. I never get the message about saving changes.

(david)
 
B

Brendan Reynolds

Me neither - but then, I've never used a query as the source object of a
subform control. I use a form in datasheet view bound to the query - perhaps
that's the answer?

OK, I've gone and talked myself into testing it now ...

Yup. I create a form with two subform controls. As the source object of one
subform control, I use a form in datasheet view bound to query. As the
source object of the second subform control, I use the query directly. I
change the width of a column in the first subform control (the one using the
form) and close the main form. No prompt. I open the main form again, and
this time change the width of one of the columns in the second subform
control, the one using the query directly. Close the form. Prompt.
 
D

david epsom dot com dot au

:~) Cool :~)

Technically, the product I work on is capable of loading
queries as subforms (it is dynamically configured), but
we never do it that way. Not because we know better, just
because we always copy each other. We want that feature,
(saving column widths) but we have just started adding
code to the subforms... so we have just locked ourselves
out of using queries instead of forms -- ain't it always
the way :~)

(david)
 
Ad

Advertisements

B

Brendan Reynolds

I've played around with using the AccessObjectProperties collection to store
the column widths in the unload event and retrieve them in the Load event.
It was a while ago now, but as far as I can remember I think it worked well.
 
Ad

Advertisements


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