Close Button

aziz rasul

Active member
Local time
Today, 21:53
Joined
Jun 26, 2000
Messages
1,935
On a form I have set the Close Button property to No so that the user is then persuaded to use the Close command button I have on the form. Everything works so far.

However if I then open any table, the Close button is not there? Any ideas why this should happen?

If I set the Close Button property to Yes on the form, then the close button appears on the tables.

If I use the following code: -

Code:
Me.CloseButton = True
on the command button, it comes up with the run-time error 2448 'You can't assign a value to this object'.
 
>>> then the close button appears on the tables <<<

I'm not sure if I quite understand what you mean. Could you explain further cheers Tony
 
If I set the CloseButton property to No, then the close button doesn't appear when I open a table.

If I set the CloseButton property to yes, then the close button does appear when I open a table.
 
Code:
Me.CloseButton = True
on the command button, it comes up with the run-time error 2448 'You can't assign a value to this object'.
In this code what property of the button are you trying to set.

try something like
Code:
 me.Closebutton.enable=True

or
Code:
me.Closebutton.visible=True
 
The close button property can only be set in design view, trying to set it or change it during run time will generate an error.
 
This is what I tried to do: -

Code:
Private Sub Form_Load()

    DoCmd.OpenForm "frmAuditForm", acDesign
    Me[COLOR="Red"].CloseButton[/COLOR].Enable = False
    DoCmd.Close acForm, "frmAuditForm", acSaveYes
    DoCmd.OpenForm "frmAuditForm", acNormal
        
End Sub

Code:
Private Sub cmdClose_Click()

    DoCmd.OpenForm "frmAuditForm", acDesign
    Me.CloseButton.Enable = True
    DoCmd.Close acForm, "frmAuditForm", acSaveYes
    DoCmd.OpenForm "frmSwitchBoard"

End Sub

When I open the form, I get the error - Compile error: Invalid qualifier on the line shown in red. If I use Me.CloseButton.Visible = False, same error.
 
This is what I tried to do: -

Code:
Private Sub Form_Load()

    DoCmd.OpenForm "frmAuditForm", acDesign
    Me[COLOR="Red"].CloseButton[/COLOR].Enable = False
    DoCmd.Close acForm, "frmAuditForm", acSaveYes
    DoCmd.OpenForm "frmAuditForm", acNormal
        
End Sub

Code:
Private Sub cmdClose_Click()

    DoCmd.OpenForm "frmAuditForm", acDesign
    Me.CloseButton.Enable = True
    DoCmd.Close acForm, "frmAuditForm", acSaveYes
    DoCmd.OpenForm "frmSwitchBoard"

End Sub

When I open the form, I get the error - Compile error: Invalid qualifier on the line shown in red. If I use Me.CloseButton.Visible = False, same error.

Where is this Load procedure? Is it in the form "frmAuditForm", if so then that's your probem, you can't open the form for design view while it's already open and running code. If this procedure is in another form then the Me will refer to that form and not "frmAuditForm".
 
Is it in the form "frmAuditForm"
Yes. OK so how do I resolve the problem? I can transfer the Load event code to the Switchboard which is opening "frmAuditForm", but how do I reset the CloseButton to Yes when closing "frmAuditForm"?
 
I resolved it by writing the code in the switchboard form.

On the Audit Form command button: -

Code:
    DoCmd.OpenForm "frmAuditForm", acDesign
    Forms!frmAuditForm.CloseButton = False
    DoCmd.Close acForm, "frmAuditForm", acSaveYes
    DoCmd.OpenForm "frmAuditForm"
    DoCmd.Maximize
    DoCmd.Close acForm, "frmSwitchBoard"

On the Open event of the Switchboard: -
Code:
    DoCmd.OpenForm "frmAuditForm", acDesign
    Forms!frmAuditForm.CloseButton = True
    DoCmd.Close acForm, "frmAuditForm", acSaveYes
Doesn't look very 'pretty' as you can see the Audit form going into design view momentarily, but it did the job. Thanks for all who contributed.
 

Users who are viewing this thread

Back
Top Bottom