kkbenj
asked on
VB6 using a Listbox selected value in a query
I have a VB6 script behind a form. Form contains a listbox (lstGuiParm) and a text box (txtBox). When the user selects a value from lstGuiParm, I want to construct a sql lookup.
But something's not correct in my WHERE clause.
But something's not correct in my WHERE clause.
Private Sub lstGuiParm_Click()
Dim fsCmd as String
fsCmd = "SELECT StatusCd from GuiParmList WHERE ParmNm = '" & **SELECTEDVALUE GOES HERE** & "'"
Set goRecSet = goConn.Execute(fsCmd)
...
End Sub
fsCmd = "SELECT StatusCd from GuiParmList WHERE ParmNm = " & Replace(**SELECTEDVALUE GOES HERE**, "'", "'")
ASKER
What I need an answer on is how to reference the selected row value from the list box.
fsCmd = "SELECT StatusCd from GuiParmList WHERE ParmNm = " & Replace(lstGuiParm.List(ls tGuiParm.S elected), "'", "'")
ASKER
.Selected
is highlighted with this error:
Compile error:
Argument not optional
is highlighted with this error:
Compile error:
Argument not optional
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That's perfect. And how do I assign it to the value displayed in the text box?
>> And how do I assign it to the value displayed in the text box?
slightly confusing.
Do you want to display the value stored in fsCmd variable in the text box ?
txtBox.Text = fsCmd
slightly confusing.
Do you want to display the value stored in fsCmd variable in the text box ?
txtBox.Text = fsCmd
ASKER
sorry for not being clear.
once I have retrieved the data from the database, I want to display the info in the text box (txtBox) on the form.
txtBox.text = goRecSet("StatusCd")
says Compile error:
Method or data member not found
once I have retrieved the data from the database, I want to display the info in the text box (txtBox) on the form.
txtBox.text = goRecSet("StatusCd")
says Compile error:
Method or data member not found
ASKER
The textbox assignment didn't work because it was a control array. fixed.
Thanks for the help!
Thanks for the help!
http://www.tek-tips.com/viewthread.cfm?qid=1461215