set .ContolBox and .CloseButton to yes

A

Angi

I know there's not a way to change the default view of a form
programatically, but is there a way to change the CloseButton and
ControlBox properties? They are currently No.

Here's what I have:
DoCmd.OpenForm "frmcustomersearch"
With Forms!frmcustomersearch
.CmdSwitch.Visible = False
.ControlBox = True
.CloseButton = True
End With

The CmdSwitch works, but the others don't. Just wondering if I'm doing
it wrong or it's just not possible.

TIA!
 
G

Graham Mandeno

Hi Angi

Sorry, these two properties can be set only in design view.

A workaround would be to disable them permanently, and provide your own
Close button which you can show or hide as required.

Another would be to intercept the close operation in the Unload event and
cancel it if you don't want the user to use the close button at that time.
 
R

Rob Oldfield

You can only change them in design view. So it would be something like...

DoCmd.OpenForm "frmcustomersearch", acDesign, , , , acHidden
With Forms!frmcustomersearch
.ControlBox = true
.CloseButton = true
End With
DoCmd.OpenForm "frmcustomersearch"

....the hidden parameter is there to minimise the amount of screen flicker
caused by opening the form in design view.
 
A

Angi

OK...so let me get this straight. I can use the button on the form
(already had that) or...

Open the form, change the design, close the form, open the form to
view, close the form, open the form, change the design back to No then
close the form again?

Won't that take a while? If so, I think I'll go with a button. Seems
like a lot of code for a little X!

Thanks guys
 

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