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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Box Selected Value Help 1

Status
Not open for further replies.

kebbers

MIS
Dec 17, 2002
5
US
I have created a combo box that is set to a stored procedure that is a select statements. I have set it to the stored procedure in the property sheet.

I also have a text box and when the use selects something from the list box, I would like my combo box to default to a particular value. Here is the function I used to do so:

Public Sub SetCboBox_Value(cbo As ComboBox, val As Variant)

Dim i As Long


For i = 0 To cbo.ListCount - 1


If cbo.Column(1, i) = val Then
cbo = cbo.Column(0, i)

GoTo FUNCT_EXIT
End If
Next i
FUNCT_EXIT:
End Sub

QUESTION IS I GET THE 2115 Error on the cbo = cbo.column(0,i). Any solutions? I have nothing on beforeupdate or any validation rules. I am confused. Thanks
 
The above code looks a little bit of a mess to me. If all you want to do is set the value of the combobox after a selection in a listbox then put your code to do this in the afterupdate event of the listbox. What are these values that you are passing to the above sub? Your error is coming because you are declaring a combobox as if it is a variable and trying to set a value to it, it isn't a variable it is an object. Regards,
gkprogrammer
 
Hi gkprogrammer,

Let me clarify, I have three combo boxes. cboTool, cboFunction, cboWindow. I have one list box. lstSymptoms. cboTool, cboFunction,cboWindow are either system stored procedure or query to populate them. lstSymptoms is a list box of symptoms. (this is a help desk app I am coding) after you select a symptom in lstSymptom, (tblsymptom has symptomID, fgn_toolID, fgn_FunctionID, fgn_WindowID, fgn_resolutionID) I would like to make the selected value of cboTool, cboFunction and cboWindow equal to what is stored in tblSymptom.

So going off of what you recommended, on lstSymptoms_Click(), I wrote the following, ( I tool out the procedure call)

cboTool.SetFocus
cboTool.Text = strTool
(strTool equal to the field)
and I still get error 2115

Any more suggestions? Am I missing something? Thanks in advance.
 
OK this makes a little more sense to me. You are trying to set the values of the three comboboxes from the respective column in the listbox depending on the row that the user selects in the listbox, correct? If so try something like this in the on_click event of the listbox:

cbotool.value = lstSymptoms.Column(1)
cboFunction.value = lstSymptoms.Column(2)
cboWindow.value = lstSymptoms.Column(3)

By the way what is the description associated with the error # 2115?

Regards,
gkprogrammer
 
gkprogrammer,

That wasn't exactly what I was doing, but you just gave me a great idea. Thanks! Hadn't thought of it. That should do the trick!

I am going to try that right now.

Kebbers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top