By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,775 Members | 2,658 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,775 IT Pros & Developers. It's quick & easy.

Referring to properties

P: n/a
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
Nov 12 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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

Nov 12 '05 #2

P: n/a
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

Nov 12 '05 #3

P: n/a
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

Nov 12 '05 #4

P: n/a
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


Nov 12 '05 #5

P: n/a
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



Nov 12 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.