473,503 Members | 12,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Referring to properties

HB
Can I refer to a controls property using a string much like I can a Control.

I want to simplify the following code:

forms!frmname!ctrlnm.visible = true
forms!frmname!ctrlnm.enabled= true
forms!frmname!ctrlnm.locked= true
forms!frmname!ctrlnm.backcolor= 124
etc

I tried:

with forms!frmname!ctrlnm
.("visible") = true
etc

but it doesn't work - Is there a collection name I should be using or is
there a better way

Thjanks in advance
Jul 17 '05 #1
5 1714
You're close.

With forms!frmname!ctrlnm
.visible = true
.enabled= true
.locked= true
.backcolor= 124
End With

--
Wayne Morgan
"HB" <fr*****@telus.net> wrote in message news:nFClb.994$SJ1.719@edtnps84...
Can I refer to a controls property using a string much like I can a Control.
I want to simplify the following code:

forms!frmname!ctrlnm.visible = true
forms!frmname!ctrlnm.enabled= true
forms!frmname!ctrlnm.locked= true
forms!frmname!ctrlnm.backcolor= 124
etc

I tried:

with forms!frmname!ctrlnm
.("visible") = true
etc

but it doesn't work - Is there a collection name I should be using or is
there a better way

Thjanks in advance

Jul 17 '05 #2
You want either:

with forms!frmname!ctrlnm
.visible = true

or, if you really need to use a string:

with forms!frmname!ctrlnm
.Properties("visible") = true

--
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand

Return mail address is invalid in a vain attempt to reduce spam.
Feedback is welcome at: gr****@mvps.org
Please post new questions or followups to newsgroup.

"HB" <fr*****@telus.net> wrote in message news:nFClb.994$SJ1.719@edtnps84...
Can I refer to a controls property using a string much like I can a Control.
I want to simplify the following code:

forms!frmname!ctrlnm.visible = true
forms!frmname!ctrlnm.enabled= true
forms!frmname!ctrlnm.locked= true
forms!frmname!ctrlnm.backcolor= 124
etc

I tried:

with forms!frmname!ctrlnm
.("visible") = true
etc

but it doesn't work - Is there a collection name I should be using or is
there a better way

Thjanks in advance

Jul 17 '05 #3
I think the closest you can get is to use CallByName.

Load UserForm1
CallByName UserForm1.TextBox1, "Text", VbLet, "New Text"
UserForm1.Show
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com ch**@cpearson.com
"HB" <fr*****@telus.net> wrote in message news:nFClb.994$SJ1.719@edtnps84...
Can I refer to a controls property using a string much like I can a Control.
I want to simplify the following code:

forms!frmname!ctrlnm.visible = true
forms!frmname!ctrlnm.enabled= true
forms!frmname!ctrlnm.locked= true
forms!frmname!ctrlnm.backcolor= 124
etc

I tried:

with forms!frmname!ctrlnm
.("visible") = true
etc

but it doesn't work - Is there a collection name I should be using or is
there a better way

Thjanks in advance

Jul 17 '05 #4
HB
OOPs

I probably didn't explain my question good enough

I eventually want to use an array with string values of the name & the value
in a for each statement so I need to be able to have the property in string
form ie form!frmname!ctrlname(propstring)
Thanks Morgan & all
"Wayne Morgan" <co***************************@hotmail.com> wrote in message
news:3O******************@newssvr16.news.prodigy.c om...
You're close.

With forms!frmname!ctrlnm
.visible = true
.enabled= true
.locked= true
.backcolor= 124
End With

--
Wayne Morgan
"HB" <fr*****@telus.net> wrote in message

news:nFClb.994$SJ1.719@edtnps84...
Can I refer to a controls property using a string much like I can a

Control.

I want to simplify the following code:

forms!frmname!ctrlnm.visible = true
forms!frmname!ctrlnm.enabled= true
forms!frmname!ctrlnm.locked= true
forms!frmname!ctrlnm.backcolor= 124
etc

I tried:

with forms!frmname!ctrlnm
.("visible") = true
etc

but it doesn't work - Is there a collection name I should be using or is
there a better way

Thjanks in advance


Jul 17 '05 #5
In that case, Graham gave you the way to go, we just need to back it up to the control's
name. Using the .Controls("name") method will allow you to concatenate together a name.

For i = 1 To 10
With forms!frmname
.Controls("ctrlnm" & i).visible = true
.Controls("ctrlnm" & i).enabled= true
.Controls("ctrlnm" & i).locked= true
.Controls("ctrlnm" & i).backcolor= 124
End With
Next i

--
Wayne Morgan
"HB" <fr*****@telus.net> wrote in message news:WWClb.1198$SJ1.524@edtnps84...
OOPs

I probably didn't explain my question good enough

I eventually want to use an array with string values of the name & the value
in a for each statement so I need to be able to have the property in string
form ie form!frmname!ctrlname(propstring)
Thanks Morgan & all
"Wayne Morgan" <co***************************@hotmail.com> wrote in message
news:3O******************@newssvr16.news.prodigy.c om...
You're close.

With forms!frmname!ctrlnm
.visible = true
.enabled= true
.locked= true
.backcolor= 124
End With

--
Wayne Morgan
"HB" <fr*****@telus.net> wrote in message

news:nFClb.994$SJ1.719@edtnps84...
Can I refer to a controls property using a string much like I can a

Control.

I want to simplify the following code:

forms!frmname!ctrlnm.visible = true
forms!frmname!ctrlnm.enabled= true
forms!frmname!ctrlnm.locked= true
forms!frmname!ctrlnm.backcolor= 124
etc

I tried:

with forms!frmname!ctrlnm
.("visible") = true
etc

but it doesn't work - Is there a collection name I should be using or is
there a better way

Thjanks in advance



Jul 17 '05 #6

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

Similar topics

3
9870
by: Jenkins | last post by:
I have a page with frames. The left frame is a list of urls. The main frame is loaded based on the url that was clicked in the left frame. Is there a way for the main frame to tell which url was...
5
1505
by: HB | last post by:
Can I refer to a controls property using a string much like I can a Control. I want to simplify the following code: forms!frmname!ctrlnm.visible = true forms!frmname!ctrlnm.enabled= true...
4
2170
by: MLH | last post by:
Somehow, I seem to be able to refer to combo-box controls in 2 distinctly different ways. A combo-box on an Access 97 form named TagCountyChooserBox seems can be referenced these ways... ...
3
3116
by: Dan Sikorsky | last post by:
How can I get the Querystring passed to the Referring Page from its referrer? I don't want the querystring coming to my current page. I want the querystring that came to the referring page, so...
2
1806
by: Elmo Watson | last post by:
Control1 is on Form1 on Form two - I'd like to access the instanciation of that control (Control1), using different properties & methods Is there a way, in VB.Net, to refer to a control on...
60
4970
by: Dave | last post by:
I'm never quite sure whether to use "this." or not when referring to fields or properties in the same class. It obviously works just fine without it but sometimes I wonder if using this....
5
3209
by: Christina | last post by:
I can't seem to find any reference for grabbing the title of the referring page, which I want to use for creating a link. i.e. document.write ("Our thanks to <a href='"+document.referrer+"'>"...
2
2283
by: paladin | last post by:
We have a strange situation where some of the referring URL's are missing from our log files. This is on .NET application on IIS 6.0. Here is what is happening: Page a.aspx has a form that...
2
1722
by: Aamir Ghanchi | last post by:
Hi, would I refer the aspx page from the class which has been instantiated in that aspx page. say I have Default.aspx. In the code page Default.aspx.cs I instantiate a class as MyClass mc =...
0
7212
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7296
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7364
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...
1
7017
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...
0
4696
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...
0
3186
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...
0
1524
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 ...
0
405
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...

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.