Link to home
Start Free TrialLog in
Avatar of rutgermons
rutgermons

asked on

obtain value from selected listbox item

Folks

I have listbox with values, if I click on the selected value I get a message showing the depicted list box item from the list  i.e. like so:


Private Sub ListBox1_Click()
MsgBox "Selected Value is " & ListBox1.Value & ""


1) how do I get the select value to display in an excek worksheet i.e. on sheet 1 field b1?
2) how do I get a listbox1.value to display and parse in SQL statement on a DB connection i.e.:

 strSQL = "SELECT * FROM MYTABLE WHERE PARAMETER = ListBox1.Value  ?

would be glad for your assistance

cheers
ASKER CERTIFIED SOLUTION
Avatar of rspahitz
rspahitz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rutgermons
rutgermons

ASKER

the paramtere could be dates too! the above seem nearly there but doesnt display on the below (this is the selected value in the valuelist)


"Backlog 01208 - Backlog request thru 12/08/13"
For dates you want to use "#" as delimiters, I think:

strSQL = "SELECT * FROM MYTABLE WHERE PARAMETER = #" & ListBox1.Value & "#"

Open in new window