To close or not

G

Guest

Hi,

I have a form with a number of controls on it. These controls are defined as
invisible. Under certain circumstances these controls are made visible.

However, when I close the form and re-open it the controls are still
visible, ie not retuning to the defined state.

Why, on re-opening the form, to they retain the change of default attribute?
Is there anything I can do to stop this happening? I know I can loop round
making them invisible again, but this resulted in focus issues which meant
one control (with the focus) wouldn't accept the visible = false.

Thanks in advance for any help.

Regards,
Arthur.
 
D

Daveo

Arthur,

Why don't you set the focus to a "safe" control such as a close button
first and then set the controls to invisibile in the On Activate event
of your form e.g.

Me.yourSafeControl.SetFocus = True
Me.yourControl1.Visible = False
Me.yourControl2.Visible = False

and so on....


Hope that's what you mean,

David
 
T

Terry Kreft

If you're closing your form with code then it should be something like

DoCmd.Close acForm, Me.Name, acSaveNo

The acSaveNo means don't change any design modifications.

BTW this is the way to set th visible property to false for all controls on
the current form.

Dim ctl As Control
DoCmd.RunCommand acCmdSelectRecord
With Me
For Each ctl In .Controls
ctl.Visible = False
Next
End With
 
R

Rick Brandt

aps said:
Hi,

I have a form with a number of controls on it. These controls are
defined as invisible. Under certain circumstances these controls are
made visible.

However, when I close the form and re-open it the controls are still
visible, ie not retuning to the defined state.

Why, on re-opening the form, to they retain the change of default
attribute? Is there anything I can do to stop this happening? I know
I can loop round making them invisible again, but this resulted in
focus issues which meant one control (with the focus) wouldn't accept
the visible = false.

Thanks in advance for any help.

Regards,
Arthur.

Are you sure you are closing the form and not just hiding it? If you actually
close the form then those changes should not "stick". Do they stick if you
close and reopen the file? I believe the newer versions allow you to make
design changes while in normal view. This option can be turned off.
 
G

Guest

Thanks David,

The problem is that the form will have no controls visible. Since it is a
sub form I cannot set the focus to another tab on the existing form I tried
that and it didn't work so I assume that the sub form tries to keep it's own
focus.

Regards,
Arthur.
 
G

Guest

Hi Rick,

I am definately closing the form, I use "DoCmd.Close acForm, Me.Name,
acSavePrompt".

I tried changing the acSavePrompt to acSaveNo and this appears to work. I
assumed this was to save data, it seems to save the settings as well.

Thanks for your help.

Regards,
Arthur.
 

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