Drop Down list

DavidCantor

Registered User.
Local time
Today, 14:03
Joined
Oct 4, 2012
Messages
66
How do I reference the selection made on a drop down control?

I have a drop down control with values AA,AH,AP and more
If AA is selectedthen I want access to show more controls for data entry relevant to AA
ANd if AH is selected then I want it to show controls relevant to AH

etc,

the drop down source is AA; AH etc and not a query
Thanks
 
How do I reference the selection made on a drop down control?

I have a drop down control with values AA,AH,AP and more
If AA is selectedthen I want access to show more controls for data entry relevant to AA
ANd if AH is selected then I want it to show controls relevant to AH

etc,

the drop down source is AA; AH etc and not a query
Thanks


Im not sure I follow you, do you mean you want to use the combo (drop down box) as a filter?

How did you create your drop down? (refer to it as a combo box, as that is the name its given in access)
 
The Combo box is a filter only showing the controls on the form that are relevant to the selection.
 
I just need the correct syntax to reference the selected option on a combo box.

something like:

me.comboname.selected.value or

me.comboname.value= "aa"
 
David:
It's not really like .NET or VB. You don't really need to reference the selected property or anything. It's simply this:
Code:
if me.combo = "AA" then
   'hide or show your controls
end if
 
This should be sufficient to access the control..
Code:
Me.comboname = "aa"
 
You need to reference the listbox items as follows:


For i = 0 To Me.YourListBox.ListCount - 1
if Me.YourListBox.Selected(i) = True then
'do something
end if
Next i
 
Not sure if they do multi select combo box anymore.. :confused:.. best to use ListBox.. looks neat too..
 
thanks,
how do I reference the values that are selected if there is more than one value?
 
ok great,

Now I want Access to display only the controls that are relevant to the values selected by setting their visble property to true


can I just enter

Code:
dim varFieldname as variant
 
For i = 0 To Me.ListSymbolSelect.ListCount - 1
 
If Me.ListSymbolSelect.Selected(i) = True Then
 
varFieldName = i
 
 Me.varFieldName.Visible = True
    Me.ListSymbolSelect.B_varFieldName_Location.Visible = True
    End If
Next i

will this iterate through the selected values and make the Location field visible for all the items selected?
 
What's varfieldname? This won't work. You can't set visible property of a variable.
Also, i is not the value of your listbox. that is the number.

To get the value of your listbox you would need to do this:

Code:
varFieldName = Me.[ListSymbolSelect].ItemData(Item)
    me.controls(varFieldName).visible = true
if that doesn't work, use this:
Code:
dim ctl as variant
for each ctl in me.controls
   if ctl.name = varFieldName then
      ctl.visible = false
   end if
next

You need to reference the actual names of the controls that are on the form.
 
This is what I have and it is not working for me
Code:
Private Sub ListSymbolSelect_Click()
Dim varFieldName As Variant
    
For i = 0 To Me.ListSymbolSelect.ListCount - 1
If Me.ListSymbolSelect.Selected(i) = True Then
varFieldName = i
'do something
End If
 Next i
Dim ctl As Variant
For Each ctl In Me.Controls
   If ctl.Name = varFieldName Then
      ctl.Visible = False
   End If
Next
   
End Sub
 

Users who are viewing this thread

Back
Top Bottom