Changing Control Properties

  • Thread starter Thread starter Frank Wagner
  • Start date Start date
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
 
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
 
-----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
 
Back
Top