PDA

View Full Version : ListBox Item queries



avadhutd2
10-16-2009, 05:22 AM
Hi,

I need help about having a litem fixed in a listbox.

Consider following scenario -

ListBox1 (with 2 columns)
Col1 Col2
Item1 Char
Item2 Char
Item3 Date
Item4 Decimal
Item5 Integer


I need to have Item3 in the ListBox2 (it should be permanant). I had done to this point as follows -


With ListBox1
e = 0
While e <= cntVar
If .List(e) = "Item3" Then
ListBox2.AddItem .List(e), 0
.RemoveItem (e)
cntVar = cntVar - 1
End If
e = e + 1
Wend
'Next
End With


If at all I transfer items from ListBox 1 to ListBox 2 they should appear below Item3

As an example -
ListBox2
Item3
Item1
Item2

I had done it as follows -

Private Sub Transfer(MoveAll As Boolean)
Dim e As Long
With ListBox1
If MoveAll = True Then
For e = 0 To .ListCount - 1
ListBox2.AddItem .List(e) 'move all items to Tobox
Next
.Clear
Else
For e = .ListCount - 1 To 0 Step -1
If .Selected(e) = True Then ' if selected then
ListBox2.AddItem .List(e), 0 ' add to start of other list
.RemoveItem e ' remove
End If
Next
End If
End With
End Sub


My first requirement is -
Item3 should never move and other items can be moved up or down but never at first position.

My Second requirement is -
I am forming a SQL query using selections in ListBox2. Here when I select the item from ListBox1 which is of column type "DATE" it should format that to DATE format while copying the SQL data to the sheet.

How to access multiple columns of a listbox in order & satisfy this requirement?

Pls guide me...Thanks!

avadhutd2
10-20-2009, 10:30 PM
Hi,

Can any one get some inputs for the query??

Thanks!

mdmackillop
10-21-2009, 05:36 AM
Can you post a sample workbook?