Populate ComboBox with Hidden Form Field Names

  • Thread starter Thread starter magmike
  • Start date Start date
M

magmike

Is it possible to populate a combo box with the names of controls on
the form whose Visible property is set to No/False?

Thanks in advance!
magmike
 
magmike said:
Is it possible to populate a combo box with the names of controls on
the form whose Visible property is set to No/False?


Yes, though you'll probably have to use a user-defined list-loading
function. But I'm not sure what you mean. First, are you talking about a
form that is open, but hidden? Second, are you talking about loading the
list with the names of all controls on the form, or only those in the form's
recordsource? Note that form's generally have controls that are not going
to contain any data, such as labels.
 
Yes. As long as you know the name of the form, you can Access the names of
the controls.
 
Yes, though you'll probably have to use a user-defined list-loading
function.  But I'm not sure what you mean.  First, are you talking about a
form that is open, but hidden?  Second, are you talking about loading the
list with the names of all controls on the form, or only those in the form's
recordsource?  Note that form's generally have controls that are not going
to contain any data, such as labels.

I'm talking about an open and visible form. However, for the
administrator (me) I would like my special tab (only visible for me)
to have a pull down menu populated with the name of data holding form
fields that are set as invisible. The AfterUpdate event would cause
that particular form field's visible property to be set to True,
making that field visible until a similar control for visible data
fields, is used to make it invisible.

I hope that makes sense.
 
Is it possible to populate a combo box with the names of controls on
the form whose Visible property is set to No/False?

Thanks in advance!
magmike

On the same form?

Dim c As Control
For Each c In Controls
If c.Properties("Visible") = False Then
ComboName.RowSource = ComboName.RowSource & c.Name & ","
End If
Next c

ComboName.RowSource = Left(ComboName.RowSource,
Len(ComboName.RowSource) - 1)
 
I'm talking about an open and visible form. However, for the
administrator (me) I would like my special tab (only visible for me)
to have a pull down menu populated with the name of data holding form
fields that are set as invisible. The AfterUpdate event would cause
that particular form field's visible property to be set to True,
making that field visible until a similar control for visible data
fields, is used to make it invisible.

I hope that makes sense.
================================================
Sure that can be done. Fill the combo box with code similar to (aircode):

Dim frm as Form
Dim ctl as Control
Dim strName as String

Set frm = Me
For Each ctl In frm.Controls
If ctl.Visible = True Then
strName = strName & ctl.Name & ";"
End If
Me.cboComboBox.RowSource = strName
Next ctl
 
magmike said:
I'm talking about an open and visible form. However, for the
administrator (me) I would like my special tab (only visible for me)
to have a pull down menu populated with the name of data holding form
fields that are set as invisible. The AfterUpdate event would cause
that particular form field's visible property to be set to True,
making that field visible until a similar control for visible data
fields, is used to make it invisible.

I hope that makes sense.


Others have answered this, I think. Post back if you're having trouble.
 
On the same form?

Dim c As Control
For Each c In Controls
If c.Properties("Visible") = False Then
    ComboName.RowSource = ComboName.RowSource & c.Name & ","
End If
Next c

ComboName.RowSource = Left(ComboName.RowSource,
Len(ComboName.RowSource) - 1)

Would this be OnCurrent of the form?
 
Nevermind, I got it!

Thanks - that is totally cool!- Hide quoted text -

- Show quoted text -

Okay, now I need help. Having trouble getting this thing to show now.
This is what I tried (i'm sure I'm way off):

Dim stControl As String
stControl = "hiddenControls.Value" ' hiddenControls is the combobox
stControl.Properties("Visible") = True

I've played around with it a bunch and can't seem to get the right
combo.

Thanks in advance for you help!
 
Okay, now I need help. Having trouble getting this thing to show now.
This is what I tried (i'm sure I'm way off):

Dim stControl As String
stControl = "hiddenControls.Value"   ' hiddenControls is the combobox
stControl.Properties("Visible") = True

I've played around with it a bunch and can't seem to get the right
combo.

Thanks in advance for you help!- Hide quoted text -

- Show quoted text -

One final thing - how can I sort the values alphebetically?

Thanks!
 
Okay, now I need help. Having trouble getting this thing to show now.
This is what I tried (i'm sure I'm way off):

Dim stControl As String
stControl = "hiddenControls.Value" ' hiddenControls is the combobox
stControl.Properties("Visible") = True

I've played around with it a bunch and can't seem to get the right
combo.

Thanks in advance for you help!


Getting what thing to show now?

I have no idea what you are trying to do here.
You originally asked how to fill a combo box with the names of
controls on a form that are not visible.
I gave you that. If you used my code, it fills a combo box rowsource
with the names of controls on the form that are not visible.
Did you set the combo box Bound Column to 1?
Did you set the combo box Column Count to 1?
Did you set the combo box Column Widths to 1"
From your previous reply it seemed to have worked for you.

Here you have a snippet of code that is unconnected to anything. I
have no idea where you placed it, nor in looking at it, what it is you
wish it to do.
 
Getting what thing to show now?

I have no idea what you are trying to do here.
You originally asked how to fill a combo box with the names of
controls on a form that are not visible.
I gave you that. If you used my code, it fills a combo box rowsource
with the names of controls on the form that are not visible.
Did you set the combo box Bound Column to 1?
Did you set the combo box Column Count to 1?
Did you set the combo box Column Widths to 1"
From your previous reply it seemed to have worked for you.

Here you have a snippet of code that is unconnected to anything. I
have no idea where you placed it, nor in looking at it, what it is you
wish it to do.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail- Hide quoted text -

- Show quoted text -


Sorry, I wasn't clear. In my original post, I mentioned that I would
be using the AfterUpdate event, to cause the selected control's
visible property to True. But I should have restated that. However,
now I am using a command button to cause the selected control in the
hiddenControls combo box, to Visible. That is where that code was
from.

Does that help?
 
Sorry, I wasn't clear. In my original post, I mentioned that I would
be using the AfterUpdate event, to cause the selected control's
visible property to True. But I should have restated that. However,
now I am using a command button to cause the selected control in the
hiddenControls combo box, to Visible. That is where that code was
from.

Does that help?

Something like this?

Dim c As Control
For Each c In Me.Controls
If c.Name = ComboName.Value Then
c.Visible = True
Exit Sub
End If '
Next

Why not just place this code in the Combo box AfterUpdate event?
 
Something like this?

Dim c As Control
For Each c In Me.Controls
If c.Name = ComboName.Value Then
    c.Visible = True
    Exit Sub
    End If '
Next

Why not just place this code in the Combo box AfterUpdate event?
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail- Hide quoted text -

- Show quoted text -

The reason I decided to use a button, is so I could have a second
button to turn it back to False. If I use the AfterUpdate, how would I
turn it off?
 
The reason I decided to use a button, is so I could have a second
button to turn it back to False. If I use the AfterUpdate, how would I
t urn it off?

Dim c As Control
For Each c In Me.Controls
If c.Name = ComboName.Value Then
    c.Visible = Not C.Visible
    Exit Sub
    End If
Next

In this case, code the command button that loads the not visible
controls into the combo box:

Me.ComboName.Rowsource = ""
Dim c As Control
For Each c In Controls
If c.Properties("Visible") = False Then
    ComboName.RowSource = ComboName.RowSource & c.Name & ","
End If
Next c
If Len(ComboName.Rowsource) > 0 Then
ComboName.RowSource = Left(ComboName.RowSource,
Len(ComboName.RowSource) - 1)
End If

Then, whenever you change a control, via the combo box, from Visible
to Not Visible, click the command button and it will re-load the combo
box and remove that now visible control from the rowsource.
 
Back
Top