Referencing an element from an instance of a form. (1 Viewer)

ojeffery

Registered User.
Local time
Today, 22:10
Joined
Nov 13, 2009
Messages
11
Hi, I've used Allen Brown's advice on how to create multiple instances of a form (can't post a link as have too few posts, but a quick google will reveal the page I'm talking about), and it's working great.

Now I need to reference an element on the form, but on an instance of the form, not the original form itself.

Each instance of the form is named dynamically when it's created; it takes its name from a field called Company.

How can I reference an element (called NewKC) of the form from a query?

Thanks in advance, Oli.
 

MarkK

bit cruncher
Local time
Today, 14:10
Joined
Mar 17, 2004
Messages
8,186
Can't you post the code that does this...
Each instance of the form is named dynamically when it's created
Also, are trying to read a property of the form, or data from a control on a form? If the latter, might it not be both easier and more reliable to read data from a table?
Mark
 

Galaxiom

Super Moderator
Staff member
Local time
, 07:10
Joined
Jan 20, 2009
Messages
12,853
This is the page referred to by the OP.
http://allenbrowne.com/ser-35.html

Allen shows how to use a collection to hold the form instances. It is a very tidy way to manage them and it allows any number of instances to be opened without explicitly managing names.

If the form is opened in very specific circumstances you can simply instantiate Public variables for each instance of the form and refer to them by the variable name.
A reference to a control in one of those instances is:
Code:
variablename.controlname

In Allen's technique the individual instances are referred to by the indexes in the collection.
So a reference to a control in one of those instances is:
Code:
collectionName("index").controlname

He uses the Hwnd property of the form's instance as the index but you can assign it any index string that suits your purpose. Similarly the caption.
 

Users who are viewing this thread

Top Bottom