473,756 Members | 3,390 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to walk Access object model - Control properties

I'm hoping someone can sanity check my understanding of the Object Model for
Forms/Controls. I'm having trouble drilling down into Control properties.

First, I have a record set with the following for a given Form:

1)Container

2)ObjectType (of each object on the Form)

3)ObjectName (of each object on the Form)

4)Property Name (of each property on the form - in every section)

Now, I want to open a form in design mode and walk the object model, trying
to match the open Form's properties with what's in the rst. (abbreviated
code and no indentation for space considerations)

Select Case rst!Container

Case "Forms"

'okay, it's a form or report

**If rst!ObjectType = "Form" Then

'it's not a control

For Each prp In frm.Properties

'don't walk each section, just match property name [1]

If prp.Name = rst!PropName Then

[do stuff with Form property]

**Else 'it's a control

For Each ctl In frm.Controls

If ctl.ControlType = rst!Ctl_ID Then

'we have match of control type

With ctl

For each prp in .Properties

If prp.Name = rst!ObjectName Then [2]

'we have match of control - e.g.

'cmdButton1, or frmSubForm1

For each varItem in .Properties

if varItem = rst!PropName Then

[do stuff with Control property]

'e.g. if it's a subform, change

'special effect; if it's a command button,

'change font

**End If

Does this look correct? [1] Can I assume that I will match the Form
property without walking each section? That is, it doesn't matter from
which section rst!PropName was taken - if I just loop through every Form
property in the open Form, I'll cover all sections. [2] will I find the the
ObjectName in ctl.Properties? I've been matching the Ctl_ID okay (i.e. 110
for a listbox) but I need to also match the name of the listbox...
Nov 12 '05 #1
8 3361
"deko" <dj****@hotmail .com> wrote:

Please ignore the posting from the "starwars" persona. He has some problems.

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
Nov 12 '05 #2
starwars <no****@tatooin e.homelinux.net > wrote:
Comments: This message did not originate from the Sender address above.
It was remailed automatically by anonymizing remailer software.


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
Nov 12 '05 #3
"starwars" <no****@tatooin e.homelinux.net > wrote
Special thanks from us all in CDMA
From the headers of the referenced message:
From: starwars <no****@tatooin e.homelinux.net >
Comments: This message did not originate
from the Sender address above.
It was remailed automatically by
anonymizing remailer software.
Please report problems or inappropriate
use to the remailer administrator at
<ab***@tatooine .homelinux.net> .
X-No-Archive: Yes


Certainly "starwars <no****@tatooin e.homelinux.net >" does not speak for "us
all in CDMA" -- he/she/it speaks only for him/her/it self.
Nov 12 '05 #4
> Please ignore the posting from the "starwars" persona. He has some
problems.

no sweat. that's the price of a public forum... but my delete button works
fine :)

I appreciate your comment
Nov 12 '05 #5
As far as I know, deko, a Form must be Open (in either Form or Design view)
for you to refer to the Properties and Controls on that Form. The Forms
Container includes all forms, not just open ones, so you'll need to open the
form you have found. Your comment may indicate that you are aware of this
and have opened the Form outside the code you showed us.

I'm not certain why you keep a record of the Container for a given Form --
the only Container (except, perhaps for user-defined Containers that you add
to the Database) in which Forms reside is, not surprisingly, the Forms
Container.

You appear to be assuming that the Controls on the Form, and their
Properties will be retrieved in the same order that they are written in the
Recordset of the Table. That may not be the case -- you may need to consider
using FindFirst to compare rather than assuming the order.

A Form has Properties other than Controls. But it also has a Controls
Collection that includes only Controls. You might want to consider using
that to pick up the Controls rather than extracting only Controls from the
Form's Properties (which do include the Controls).

Larry Linson
Microsoft Access MVP


"deko" <dj****@hotmail .com> wrote in message
news:ng******** *********@newss vr29.news.prodi gy.com...
I'm hoping someone can sanity check my understanding of the Object Model for Forms/Controls. I'm having trouble drilling down into Control properties.

First, I have a record set with the following for a given Form:

1)Container

2)ObjectType (of each object on the Form)

3)ObjectName (of each object on the Form)

4)Property Name (of each property on the form - in every section)

Now, I want to open a form in design mode and walk the object model, trying to match the open Form's properties with what's in the rst. (abbreviated
code and no indentation for space considerations)

Select Case rst!Container

Case "Forms"

'okay, it's a form or report

**If rst!ObjectType = "Form" Then

'it's not a control

For Each prp In frm.Properties

'don't walk each section, just match property name [1]

If prp.Name = rst!PropName Then

[do stuff with Form property]

**Else 'it's a control

For Each ctl In frm.Controls

If ctl.ControlType = rst!Ctl_ID Then

'we have match of control type

With ctl

For each prp in .Properties

If prp.Name = rst!ObjectName Then [2]

'we have match of control - e.g.

'cmdButton1, or frmSubForm1

For each varItem in .Properties

if varItem = rst!PropName Then

[do stuff with Control property]

'e.g. if it's a subform, change

'special effect; if it's a command button,

'change font

**End If

Does this look correct? [1] Can I assume that I will match the Form
property without walking each section? That is, it doesn't matter from
which section rst!PropName was taken - if I just loop through every Form
property in the open Form, I'll cover all sections. [2] will I find the the ObjectName in ctl.Properties? I've been matching the Ctl_ID okay (i.e. 110 for a listbox) but I need to also match the name of the listbox...

Nov 12 '05 #6
starwars <no****@tatooin e.homelinux.net > wrote:
Comments: This message did not originate from the Sender address above.
It was remailed automatically by anonymizing remailer software.


Please ignore the above posting.

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
Nov 12 '05 #7
The Form in a Subform Control, even when displayed, is not "Open" -- it is
accessible as the Form property of the Control but does not exhibit the
attributes of an Open Form.

I think you will need some logic to determine the Form that is embedded as
the Source Object in the Subform Control, and open in separately, in Design
View.

Yes, a Subform Control does have Properties that apply to the Subform
Control in addition to the Form embedded in the Subform Control having its
own Properties.

Larry Linson
Microsoft Access MVP

"deko" <dj****@hotmail .com> wrote in message
news:MS******** **********@news svr25.news.prod igy.com...
Here's another crack at it....

Select Case rst!Container
Case "Forms"
acc.DoCmd.OpenF orm rst!Parent, View:=acDesign, WindowMode:=acH idden
Set frm = acc.Forms(rst!P arent)
Select Case rst!ObjectType 'always either "Detail", "Form", the name of a Control, or the name of a SubForm
Case "Form"
For Each prp In frm.Properties
If prp.Name = rst!PropName Then
prp = rst!NewValue 'change any form property
acc.DoCmd.Save acForm, frm.Name
LogChange rst!Parent, rst!ObjectName, _
ctl.ControlType , lngOldCtl, _
rst!PropName, prp.Type, strOld, _
prp.Value, rst!Property_ID
End If
Next
Case "Detail"
'do something with Detail
Case Else 'we have a control or subform
For Each ctl In frm.Controls
If ctl.ControlType = 112 Then
'Close parent, open subform - walk controls
elsewhere - BUT - things like "SpecialEff ect" are peculiar to the form as a *control* on the parent form... am I right?
ElseIf ctl.ControlType = rst!Ctl_ID Then 'e.g. 109
for TextBox
With ctl
For Each prp In ctl.Properties
If prp = rst!ObjectName Then 'e.g.
"txtLastNam e"
prp.Value = rst!NewValue 'e.g.
"Tahoma"
End If
Next
End With
End If
Next
End Select
Case "Reports"

Nov 12 '05 #8
> The Form in a Subform Control, even when displayed, is not "Open" -- it is
accessible as the Form property of the Control but does not exhibit the
attributes of an Open Form. 10-4
I think you will need some logic to determine the Form that is embedded as
the Source Object in the Subform Control, and open in separately, in Design View. see below...
Yes, a Subform Control does have Properties that apply to the Subform
Control in addition to the Form embedded in the Subform Control having its
own Properties.

10-4
Continuing with the example of trying to set the SubForm property
"SpecialEff ect" on a SubForm Control - I don't believe opening the SubForm
in design mode will help since there is no SpecialEffect property for the
form itself, but only on the SubForm control.

So, I looped through each of the 5 properties like this:

For Each ctl In frm.Controls
If ctl.ControlType = 112 Then
With ctl
For Each prp In ctl.Properties
Debug.Print prp.Inherited & " (Inherited)"
Debug.Print prp.Name & " (Name)"
'Debug.Print prp.Properties & "(Propertie s)"
For Each varItem In prp.Properties
Debug.Print varItem & " (prp.Properties _Item)"
Next
Debug.Print prp.Type & "(Type)"
Debug.Print prp.Value & "(Value)"
Next
End With

See results below...

The problem now is identifying which property to change: the first property
returned [1] has the name of the SubForm for prp.Value, and then about the
20th [2] has SpecialEffect property, with the corresponding prp.Value [3]
that I'm after.

In the rst, there may be several ctl.ControlType = 112 (SubForms).
Therefore, I need to identify which SubForm I'm working with - prior to the
control structure "For Each prp In ctl.Properties. .." - that way I can
change the right prp.Value for the right SubForm. Is there a way to
identify the control with a Control property?

There does not appear to be a "Ctl.Name", but there is:
Ctl.ItemData
Ctl.Object
Ctl.Parent
etc...

but I'm not sure how to work with these, or if they can help me identlfy
the name of the SubForm.

Alternatively, if I can rely on the order in which the properties are
returned, I could use something like this:

With ctl
For Each prp In ctl.Properties
If prp.Value = rst!ObjectName Then
Find Next prp.Name In ctl.Properties <<==== ??? pseudo code
Where prp.Name = rst!PropName <<=== ???
prp.Value = rst!NewValue
End If
Next
End If
Next
End With

Any suggestions on how to identify the Subform in question?

Thanks again for your help - I appreciate your patience with this one...

EventProcPrefix (Name)

(prp.Properties _Item)

8(Type)

frmPropertiesDa taSheet(Value) <<=== * [1]

Name (Name)

(prp.Properties _Item)

8(Type)

frmPropertiesDa taSheet(Value)

ControlType (Name)

(prp.Properties _Item)

2(Type)

112(Value)

SourceObject (Name)

(prp.Properties _Item)

8(Type)

frmPropertiesDa taSheet(Value)

LinkChildFields (Name)

(prp.Properties _Item)

8(Type)

(Value)

LinkMasterField s (Name)

(prp.Properties _Item)

8(Type)

(Value)

StatusBarText (Name)

(prp.Properties _Item)

8(Type)

(Value)

Visible (Name)

(prp.Properties _Item)

11(Type)

True(Value)

DisplayWhen (Name)

(prp.Properties _Item)

2(Type)

0(Value)

Enabled (Name)

(prp.Properties _Item)

11(Type)

True(Value)

Locked (Name)

(prp.Properties _Item)

11(Type)

False(Value)

TabStop (Name)

(prp.Properties _Item)

11(Type)

True(Value)

TabIndex (Name)

(prp.Properties _Item)

2(Type)

0(Value)

CanGrow (Name)

(prp.Properties _Item)

11(Type)

True(Value)

CanShrink (Name)

(prp.Properties _Item)

11(Type)

False(Value)

Left (Name)

(prp.Properties _Item)

2(Type)

1514(Value)

Top (Name)

(prp.Properties _Item)

2(Type)

764(Value)

Width (Name)

(prp.Properties _Item)

2(Type)

12240(Value)

Height (Name)

(prp.Properties _Item)

2(Type)

6645(Value)

SpecialEffect (Name) <<==== * [2]

(prp.Properties _Item)

2(Type)

2(Value) <<=========== * [3]

BorderStyle (Name)

(prp.Properties _Item)

2(Type)

1(Value)

OldBorderStyle (Name)

(prp.Properties _Item)

2(Type)

1(Value)

BorderWidth (Name)

(prp.Properties _Item)

2(Type)

0(Value)

BorderLineStyle (Name)

(prp.Properties _Item)

2(Type)

0(Value)

BorderColor (Name)

(prp.Properties _Item)

3(Type)

0(Value)

Section (Name)

(prp.Properties _Item)

2(Type)

0(Value)

Tag (Name)

(prp.Properties _Item)

8(Type)

(Value)

InSelection (Name)

(prp.Properties _Item)

11(Type)

False(Value)

OnEnter (Name)

(prp.Properties _Item)

8(Type)

(Value)

OnExit (Name)

(prp.Properties _Item)

8(Type)

(Value)


Nov 12 '05 #9

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

Similar topics

6
4752
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much appreciated. Thanks in advance
7
1566
by: Adrian Gonzalez | last post by:
Hi, I have a database which is used for a model policy we have and i have a form where the paragraphs for the policy is put. Now i need a way in which i can highlight or underline the changes that are made by anyone for the model policy data. I have searched on google and a number of sites but come up empty handed. Any help would be appreciated.
20
3345
by: Olav.NET | last post by:
I am a .NET/C++ developer who is supposed to do some work with Access. I do not know much about it except for the DB part. Questions: *1* I am looking for INTENSIVE books to get quickly up to speed. I like books with practical exercises, and also with test questions (like cert books) *2*
8
1670
by: Joel Reinford | last post by:
I would like to build a class that has properties which can be accessed by string names or index numbers in the form of MyClass.Item("LastName"). The string names or item index values would be populated by a data-driven loop. I need a few pointers to get me started in the right direction. I'm pretty sure that I need a default Item property but I'm not sure how to create that or index the other properties. A short code example is below ...
5
2877
by: c676228 | last post by:
Hi, I guess I am confused. In aspx script, I mean (you won't use Codebehind="enrollinfo.aspx.vb", but mix code with html and code together) You can access user control's property directly. Since I am useing visual studio .net, the html and code are seperated. I have the following aspx code which has two user controls: <%@ Register TagPrefix="Subway" TagName="Peopleinfo" Src="Peopleinfo.ascx" %> <%@ Register TagPrefix="Subway"...
5
2688
by: Lyle Fairfield | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/callnetfrcom.asp The Joy of Interoperability Sometimes a revolution in programming forces you to abandon all that's come before. To take an extreme example, suppose you have been writing Visual Basic applications for years now. If you're like many developers, you will have built up a substantial inventory of code in that time. And if you've been following...
26
5694
by: yb | last post by:
Hi, Is there a standard for the global 'window' object in browsers? For example, it supports methods such as setInterval and clearInterval, and several others. I know that w3c standardized several parts of the DOM, but this does not include the window object. Thank you
12
7502
by: Doug | last post by:
Hi, I learned a little about the model view presenter pattern at a conference this last week and am experimenting with it. It's working pretty well but I have a question. I am trying to use it to reset info in a combo box. Below is some sample code for my view interface and the presenter: public interface IDevToolView
10
3373
by: Les Desser | last post by:
In article <fcebdacd-2bd8-4d07-93a8-8b69d3452f3e@s50g2000hsb.googlegroups.com>, The Frog <Mr.Frog.to.you@googlemail.comMon, 14 Apr 2008 00:45:10 writes Not sure if I quite follow that. 1. Data encrypted by AES key 2. AES key encrypted with Asymmetric public key (?)
0
9869
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9838
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9708
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7242
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5140
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2665
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.