Convert string to object ??

STGE

New member
Local time
Tomorrow, 00:13
Joined
Sep 26, 2008
Messages
6
Hi

Im working on an MS Access database that has several forms each containing several comboboxes.

My problem is that I want to make my database more dynamic so I dont have to change a lot of code each time a new form is added.

To use the forms you set up a lot of comboboxes and press a button to enter a function. I want to stor all the values of these comboboxes in an array, but is it possible to me to to that without writing the names of all the comboboxes?

All cboboxes starts with cbo_ and then a name (all the names are already stored in an array):

Code:
    Dim form As form
    Dim cbo As ComboBox
 
    set form = Form_f_Motors
 
    Dim temp As String
    temp = "cbo_" & array_field(0, 2)
 
'    Set cbo = form.temp ''''' of couse this does not work but hos to convert object to string?? ''
 
'    Set cbo = temp
 
    For i = LBound(array_field) To UBound(array_field)
        array_field(i, 2) = form.cbo_name.Value
    Next

Similar all the forms are called Form_f_name, this name is send to the function. The form that has to be used in the function can be put together in this string : "Form_f_" & equipment
But how to convert this string to an object?

Alternativly is it possible to get a list of all the objevts (comboboxes) in a form?
 
You would use:
Code:
Forms(YourFormVariableHere).Controls(YourControlVariableHere)
 
Brilliant! Just what I needed!

Thank you very much and have a nice weekend!
 
You would use:
Code:
Forms(YourFormVariableHere).Controls(YourControlVariableHere)
I needed this as well, setting values on checkboxes representing each US state and each US territory.

Thanks!
 

Users who are viewing this thread

Back
Top Bottom