Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code to change a property on all forms

Status
Not open for further replies.

planetdrouin

Technical User
Dec 29, 2001
36
US
About a month ago I saw some code either here or "The Access Web" which allowed you to change a particular property on all forms. For the life of me I can't seem to find it again. For instance, it was very useful for changing the menu bar property on all forms.

Does anyone happen to know where to find this code?

Thanks

Lawrence

 
I'm not sure what code you're referring to, but here's some code that might get you going, anyway. These are two procedures I place in a module and use to change the properties of selected textboxes on all forms at once. The first sets an input mask and format for all textboxes with 'date' in their name. The second does the same for all textboxes with 'phone' in their name. This allows me to set or change properties for all controls of a particular type on all my forms, all in one fell swoop.

The modifications to merely modify some properties on all forms should be pretty simple.

(Setting format and input mask in design view of the table do what my procedures to, to some extent, but that method is limited because the values entered in table design are only used when a control for the field is placed on a form. If you change things later you need to reinsert the control or edit properties manually. -- Herb

---------------------------------------------------------
Public Sub ChangeDates()
On Error GoTo Err_cmd


Dim frmCollection As Object
Set frmCollection = CurrentProject.AllForms

Dim ctl As Control
Dim frm As Object

For Each frm In frmCollection
DoCmd.OpenForm frm.Name, acDesign
For Each ctl In Forms(frm.Name).Controls
If ctl.ControlType = acTextBox Then
If ctl.Name Like "*date*" Then
Debug.Print ctl.Name
ctl.InputMask = "99/99/00;;#"
ctl.Format = "mm/dd/yy"
End If
End If
'Debug.Print ctl.ControlType
Next ctl

DoCmd.Close acForm, frm.Name

Next frm

Exit_Sub:
Exit Sub

Err_cmd:
MsgBox Err.Description
Resume Exit_Sub

End Sub
-------------------------------------
Public Sub ChangePhones()
On Error GoTo Err_cmd


Dim frmCollection As Object
Set frmCollection = CurrentProject.AllForms

Dim ctl As Control
Dim frm As Object

For Each frm In frmCollection
DoCmd.OpenForm frm.Name, acDesign
For Each ctl In Forms(frm.Name).Controls
If ctl.ControlType = acTextBox Then
If ctl.Name Like "*phone*" Then
Debug.Print ctl.Name
ctl.InputMask = "!(999) 000-0000;;#"
'ctl.Format = "mm/dd/yy"
End If
End If
Next ctl

DoCmd.Close acForm, frm.Name

Next frm

Exit_Sub:
Exit Sub

Err_cmd:
MsgBox Err.Description
Resume Exit_Sub

End Sub
-----------------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top