Close the Property (F4) window with code

  • Thread starter Thread starter Tony_VBACoder
  • Start date Start date
T

Tony_VBACoder

Does anyone know if it is possible to close
the "Properties" (F4) window of a Form when it opens? I
have a Form that has the "Modal" property set to "Yes",
and if the user has the Properties (F4) window for this
Form open, the Properties (F4) window will stay open on
top of my Form and cannot be closed by clicking on the "X"
button of the Properties (F4) window.
 
Dear Tony..

If you want to avoid seeing the properties menu when using the form, go to
the form's property sheet, and under the tab for "Other", you can set the
property called "Allow Design Changes" to "Design View Only..

HTH
Fred Boer
 
Fred, thank you. I was not aware of this property and as
a result, I have gone through all my other Forms where
this same situation may occur and changed them also.
 
Expanding on Fred's advice here is a nifty function written by MVP Sandra Daigle which will change
this setting on ALL forms in just a few seconds.

1. Try this on a copy of your database!
2. Copy/Paste the code to a new standard module
3. Compile the code and save the module as modChangeDesignProperty
4. Go to the Immediate Window (CTRL G) and type in DisableDesignChanges and then hit Enter.
5. Hang on as each form is opened in Design View, the property changed, and then saved.

'Code Start:
Public Function DisableDesignChanges()
' Comments :
' Parameters: -
' Modified : 07/31/2000 Sandra Xena Daigle
'

On Error GoTo Proc_Err
Dim dbs As DAO.Database
Dim doc As Document
Dim lngI As Long
Set dbs = CurrentDb
lngI = 1
For Each doc In dbs.Containers("Forms").Documents
DoCmd.OpenForm doc.name, acDesign
Forms(doc.name).AllowDesignChanges = False
lngI = lngI + 1
If (lngI Mod 15 = 0) Then
DoEvents
End If
DoCmd.Close acForm, Forms(doc.name).name, acSaveYes
Next

Proc_Exit:
Set doc = Nothing
Set dbs = Nothing
Exit Function

Proc_Err:
If Err.Number = 2465 Then
DoCmd.Close acForm, Forms(doc.name).name, acSaveNo
GoTo Proc_Exit
Else
MsgBox Err.Number & vbCrLf & Error$
Resume Next
End If
End Function
' Code End
 
Back
Top