Changing Control Properties

F

Frank Wagner

I want to change the visible property of certain control
button contols depending on the input from users, and
would like to select the controls with a VBA statement.

I have tried the following and it gives me the error
message "Object variable or With block variable not
set". Having never done this before, I'm not sure if the
code is even close. Any help would be appreciated

Dim ctlControlButton As Control

ctlControlButton = T1_6 'T1_6 is the name of the control

Me.[ctlContolButton].Visible = False

Thanks

Frank Wagner
 
M

Marshall Barton

Frank said:
I want to change the visible property of certain control
button contols depending on the input from users, and
would like to select the controls with a VBA statement.

I have tried the following and it gives me the error
message "Object variable or With block variable not
set". Having never done this before, I'm not sure if the
code is even close. Any help would be appreciated

Dim ctlControlButton As Control

ctlControlButton = T1_6 'T1_6 is the name of the control

Me.[ctlContolButton].Visible = False


You've mixed the usage of the control object with the name
of the control. Try this:

Dim strControlButton As String
strControlButton = "T1_6 'T1_6" ' is the name of the control
Me(strContolButton).Visible = False

or just
Me.[T1_6 'T1_6].Visible = False
 
G

Guest

-----Original Message-----
Frank said:
I want to change the visible property of certain control
button contols depending on the input from users, and
would like to select the controls with a VBA statement.

I have tried the following and it gives me the error
message "Object variable or With block variable not
set". Having never done this before, I'm not sure if the
code is even close. Any help would be appreciated

Dim ctlControlButton As Control

ctlControlButton = T1_6 'T1_6 is the name of the control

Me.[ctlContolButton].Visible = False


You've mixed the usage of the control object with the name
of the control. Try this:

Dim strControlButton As String
strControlButton = "T1_6 'T1_6" ' is the name of the control
Me(strContolButton).Visible = False

or just
Me.[T1_6 'T1_6].Visible = False

--
Marsh
MVP [MS Access]
.
Marshall:

It works like a charm.

Thanks

Frank
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top