Forms Collection

  • Thread starter Thread starter Nelson
  • Start date Start date
N

Nelson

I want to be able to change the text in either a label or textbox, for all
forms in a database through code. I believe the process would involve the
forms collection or group, however I have not been able to figure it out.
Can you help?

Thanks
Nelson W
 
If I understand Access correctly, the "Forms" collection only actually
contains the forms that are open at any particular time in the database.
However, I think what you are looking for is the currentproject.AllForms
collection.

To loop through all of the forms in the current project, you could type the
following in a module and it would spit out the names of all of the forms in
the immediate window.

for each frm in currentproject.AllForms
debug.Print frm.name
next

HTH
Dale
 
I had some code that would use the .AllForms collection to open each form
using DoCmd.OpenForm .... acDesign and then loop through the controls on the
form. Its not too difficult. I'm out of town a tthe moment but will look when
I'm back.
 
David H said:
I had some code that would use the .AllForms collection to open each form
using DoCmd.OpenForm .... acDesign and then loop through the controls on
the
form. Its not too difficult. I'm out of town a tthe moment but will look
when
I'm back.


Something like:

'------ start of code snippet ------
Dim ao As AccessObject
Dim ctl As Access.Control

For Each ao In CurrentProject.AllForms

DoCmd.OpenForm ao.Name, acDesign, _
WindowMode:=acHidden

With Forms(ao.Name)

' ... make design changes to form ...

' To loop through all the controls on the form, use this:
For Each ctl in .Controls

' ... do something with ctl ...

Next ctl


' Close and save the form.
DoCmd.Close acForm, .Name, acSaveYes

End With

Next ao
'------ end of code snippet ------
 
Nelson said:
I want to be able to change the text in either a label or textbox, for all
forms in a database through code. I believe the process would involve the
forms collection or group, however I have not been able to figure it out.

Do you want to do this once or on a regular basis such as when doing
internationalizing of your app?

If once see the Scan and replace utilities section at the Microsoft
Access third party utilities, products, tools, modules, etc. page at
my website.
http://www.granite.ab.ca/access/thirdparty.htm

If a regular basis we had a discussion on this topic a while back.

http://groups.google.ca/group/comp....0d4/8e6cf8538175f20d?hl=en&q=form+table+label

Also see Microsoft Access Multilingual/Localization Solutions
http://www.granite.ab.ca/access/multilingual.htm

Tony

--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
Back
Top