Changing a control property using a dynamically created string

  • Thread starter Thread starter Rick Schneider
  • Start date Start date
R

Rick Schneider

Is it possible to change a property of a control/tab usine a string? For
example, I tried:

Dim Test_Form As String
Test_Form = "forms![frm_Main_Contacts]"
Test_Form.Tab_Control_Subforms.Value = 0

where "Tab_Control_Subforms" is a tab control. This does not work. Is
there some way to do this?

Thanks,

Rick
 
Rick Schneider said:
Is it possible to change a property of a control/tab usine a string? For
example, I tried:

Dim Test_Form As String
Test_Form = "forms![frm_Main_Contacts]"
Test_Form.Tab_Control_Subforms.Value = 0

where "Tab_Control_Subforms" is a tab control. This does not work. Is
there some way to do this?


Using a variable for the form name:

Dim Test_Form As String
Test_Form = "frm_Main_Contacts"
Forms(Test_Form)!Tab_Control_Subforms.Value = 0


Using a variable for the form name, and another variable for the control
name:

Dim Test_Form As String
Dim ControlName As String

Test_Form = "frm_Main_Contacts"
ControlName = "Tab_Control_Subforms"

Forms(Test_Form).Controls(ControlName).Value = 0
 
Exactly what I needed; many thanks, Dirk.

Rick

Dirk Goldgar said:
Rick Schneider said:
Is it possible to change a property of a control/tab usine a string? For
example, I tried:

Dim Test_Form As String
Test_Form = "forms![frm_Main_Contacts]"
Test_Form.Tab_Control_Subforms.Value = 0

where "Tab_Control_Subforms" is a tab control. This does not work. Is
there some way to do this?


Using a variable for the form name:

Dim Test_Form As String
Test_Form = "frm_Main_Contacts"
Forms(Test_Form)!Tab_Control_Subforms.Value = 0


Using a variable for the form name, and another variable for the control
name:

Dim Test_Form As String
Dim ControlName As String

Test_Form = "frm_Main_Contacts"
ControlName = "Tab_Control_Subforms"

Forms(Test_Form).Controls(ControlName).Value = 0


--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)
 
Back
Top