Global Properties Change

J

JenK

In my database I have around 100 forms. I want to change the toolbar and menu
bar on each to the same one. Is there an easy way to get this changed or do I
have to go into each and every form to change this?
 
D

Danny J. Lesandrini

I wrote an article for Database Journal about that. You can see the article and
download some sample code here ...

http://www.databasejournal.com/features/msaccess/article.php/3631631/Access-Object-Enhancifier.htm

Below is some code I scraped off the article html page. You'll need additional
code to loop through the collection of forms and process them all. This one takes
the name of a single form and processes all controls.

Danny
Public Function ModifyFormControls(ByVal sForm As String) As Boolean
On Error GoTo Err_Handler

Dim frm As Access.Form
Dim ctl As Access.Control
Dim strName As String
Dim strPrefix As String
Dim strStatusText As String
Dim strMsg As String

' Begin by opening the form in design view, so it may be
' accessed by our Form object variable.
DoCmd.OpenForm sForm, acDesign
Set frm = Forms(sForm)

' Loop through all the controls on the form, checking its type
to ' know how to proceed. (Labels don't have properties of a text box.)
For Each ctl In frm.Controls
If Left(ctl.Name, 3) = "lbl" Then Stop
Select Case ctl.ControlType
Case acLabel
strPrefix = "lbl"
strName = Replace(ctl.Caption, " ", "")
strStatusText = ""
Case acTextBox
strPrefix = "txt"
strName = ctl.ControlSource
strStatusText = AddSpacesToName(strName)
Case acCheckBox
strName = ctl.ControlSource
strPrefix = "chk"
strStatusText = AddSpacesToName(strName)
Case acListBox
strPrefix = "lst"
strName = ctl.ControlSource
strStatusText = AddSpacesToName(strName)
Case acComboBox
strPrefix = "cbo"
strName = ctl.ControlSource
strStatusText = AddSpacesToName(strName)
Case Else
strPrefix = "obj"
strName = ctl.Name
strStatusText = ""
End Select

strName = UCase(Left(strName, 1)) & Mid(strName, 2)

' set the control's Name property
ctl.Name = strPrefix & strName

' For data controls, set their status bar text and
' tool tip text properties.
If
strStatusText <> "" Then
ctl.StatusBarText = strStatusText
ctl.ControlTipText = strStatusText
End If
' Just for fun, report the RowSource property to
' user if control is the sort that has one.
If ctl.ControlType = acComboBox Then
strMsg = ctl.Name & vbCrLf & "SQL = " & ctl.RowSource
MsgBox strMsg, vbInformation, "List/Combo Property"
End If
Next

DoCmd.Close acForm, sForm, acSavePrompt

Exit_Here:
Set ctl = Nothing
Set frm = Nothing
Exit Function
Err_Handler:
MsgBox Err.Description, vbExclamation, "Error"
Resume Next
End Function-- Danny J. (e-mail address removed)
 

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