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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scanning all form's object from the MdiParent Form 1

Status
Not open for further replies.

swreng

MIS
Jun 22, 2006
90
GR
Dear,

I have a project with about 300 forms.
In a table of my database i have their names.

So i would like to record all the objects of every form in my db by writing something on the mdi parent form.

I try with CreateObject and GetObject methods by passing the string of the form's name, but i have the error message Activex component can't create object.

Any ideas?

Many thanks


I call the following Sub on The Load event of MdiForm


Private Sub FillObjects(frmName As string)

Dim obj as Object
Dim ctl as Control

set obj=CreateObject(frmName)
' GetObject has also the same problem

for each ctl in obj

' Execute Commands on the database

next


End Sub
 
Basically all you need is a list of all the form names, which are stored in a Access or Excel table, or even jsut a text file.

Then loop through the form names and in each loop use a For/Each Obj

If you need an easier way to get all the form names, then look at MZTools from and use the statistics option to export a list of all objects.

Then delete all lines which are not form names and then import this list into a new Excel or Access table.
 
Hi SBerthHold,

I have already the names of the forms. I don't really need that. I want to scan all the form's object from their names which i have, from the Mdi Parent Form.

So where should i put the the For/Each Obj loop?
This willl give me the objects of the MainForm if i call it from that point.


Many Thanks
 
>I try with CreateObject and GetObject methods by passing the string of the form's name

Ok, so you need to be able to open a form by (string) name - which I've covered here before. Try thread222-795815 as one example.

Your

set obj=CreateObject(frmName)

now becomes

set obj = FormByName(frmName)

and then the rest of your code should work ok
 
Thank you strongm

Your post is very useful for that i want to do.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top