Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List View

Status
Not open for further replies.

Marryp

Technical User
May 28, 2001
129
CA
What is the right property to get the value of listview?
If the syntax used in Textbox.Value what would it be for listview?

 
If u mean how to get the value from a listbox... You need to loop though the list box to see how many items were selected, if multi-select is enabled.

For intICnt = 0 To Me.lst_B_UNITS.ListCount - 1 'This loops from first entry in the list
If Me.lst_B_UNITS.Selected(intICnt) Then
lcB_Unit = Me.lst_B_UNITS.Column(0, intICnt)
...
Next intICnt

If not using Multi-Select, then u should be able to say,
Me.lst_B_UNITS.Value. U can use Me.lst_B_UNITS.ListIndex to locate which item you are positioned on in the list. remember u start at zero, for the first item though.

htwh,
Steve Medvid
"IT Consultant & Web Master"
 
Steve,

For listbox I just use Me!ListBox and it works fine but I changed the control to an ActiveX - ListView.

I tried using .ListIndex and I get an error: "Object doesn't support this property or method"
 
Below is an eg where all values selected are sent to text boxes, and then finally grouped together. Will only work when multi select is set to simple.

Hope it helps.

Private Sub CBNEW1_AfterUpdate()
'can not have more than 4 selected net id's
If Me!CBNEW1.ItemsSelected.Count >= 5 Then
MsgBox "The maximum Number of Network Id's that can be selected is 4.", vbInformation, "INFORMATION MANAGEMENT"
Exit Sub
End If
'reset hidden text boxes to null
Me![NETID1] = Null
Me![NETID2] = Null
Me![NETID3] = Null
Me![NETID4] = Null
'update hidden text boxes with selected values
'then update net id text box with these values from hidden
'text boxes
Dim strControlName As String
Dim intControlNumber As Integer
Dim frm As Form, ctl As Control
Dim varItm As Variant, intI As Integer
intControlNumber = 1
Set frm = Forms!frm_nonroutineoperations
Set ctl = frm!CBNEW1
For Each varItm In ctl.ItemsSelected
For intI = 0 To ctl.ColumnCount - 1
strControlName = "NETID" & Format(intControlNumber)
Me.Controls(strControlName) = ctl.ItemData(varItm)
intControlNumber = intControlNumber + 1
Next intI
Next varItm
[NETWORK_ID] = [NETID1] & " " & [NETID2] & " " & [NETID3] & " " & [NETID4]

'see on current for code that deselects the list as you scroll through
End Sub
 
That is good for listbox.

Now how do I get the value of a LIST VIEW?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top