473,326 Members | 2,108 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Looping through forms then the controls.

Hello,

I'm trying to loop through forms by doing a "For Each" in the Currentdb.
I'm doing this like the following;

Dim db as dao.database
Dim docLoop as document
Dim ctrl as control
Set db = CurrentDb

With db.Containers!Forms
For Each docloop In .Documents

'Code to set the form here
'set frm = db.containers.whatever (not sure how to do this, hence
the question)

For each ctrl in frm.controls
ctrl.backcolor = 16777215
Next ctrl

Next docloop

End With

This is kind of air code, but you should get the idea. The step I'm missing
is converting the Document to a Form object.

Any ideas?

Thanks!
Nov 13 '05 #1
1 6389
The Documents collection gives you the name of each form, but you then have
to OpenForm before you can get at the controls and their properties.

In Access 2000 and later, it might be easier to use the AllForms collection.
For an example of that approach, opening each form hidden, looping through
its controls, and closing the form again. see:
http://allenbrowne.com/ser-46.html

The example has a bit more complexity than you need, because it is actually
making changes to work around an A2003 problem where the form flickers, but
it shows the approach.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Jozef" <me@you.com> wrote in message
news:unHZe.556288$s54.379950@pd7tw2no...
Hello,

I'm trying to loop through forms by doing a "For Each" in the Currentdb.
I'm doing this like the following;

Dim db as dao.database
Dim docLoop as document
Dim ctrl as control
Set db = CurrentDb

With db.Containers!Forms
For Each docloop In .Documents

'Code to set the form here
'set frm = db.containers.whatever (not sure how to do this, hence
the question)

For each ctrl in frm.controls
ctrl.backcolor = 16777215
Next ctrl

Next docloop

End With

This is kind of air code, but you should get the idea. The step I'm
missing is converting the Document to a Form object.

Any ideas?

Thanks!

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: TD | last post by:
This is the code under a command button - Dim ctl As Control For Each ctl In Me.Controls If ctl.BackColor <> RGB(255, 255, 255) Then ctl.BackColor = RGB(255, 255, 255) End If Next ctl
7
by: Hai Nguyen | last post by:
I have another question. I'm trying to loop through all the textboxes on a web application. The snippet is below //foreach(WebControl ctr in Page.Controls) foreach(Control ctr in Page.Controls)...
7
by: Mike Bulava | last post by:
I have created a base form that I plan to use throughout my application let call the form form1. I have Built the project then add another form that inherits from form1, I add a few panel controls...
4
by: Poppy | last post by:
How can I loop through controls on a form and find out what type they are. I want to loop through controls on a webform and if they are visible textboxes change there value if NULL to "na". Also...
3
by: Geraldine Hobley | last post by:
Hello, In my project I am inheriting several forms. However when I inherit from a form and add additional subroutines and methods to my inherited form I get all sorts of problems. e.g. I sometimes...
7
by: astro | last post by:
I am not farmilar with the object model for webforms. I want to loop through the web form controls - pulling out the checkboxes on the form like the following: For Each ctrl In Me.Controls ...
5
by: greg | last post by:
HI, I have an asp page that loops through the forms collection gathering data from input controls that web surfers have entered in. The problem I have is when I get to the submit button, I get...
2
by: pob | last post by:
Whats the difference between using a control or a listbox when looping thru a listbox. In example 1 it dims a listbox and an example 2 it dims a control. Please explain. Thanks in advance ...
1
by: Michael R | last post by:
Hi All. I'm trying to delete conditions from all the controls in my form via VBA command. This code doesn't work though: Dim frm As Form Dim myControl As Control Set frm = Forms!Customers ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.