Populating combo box with results from SP
Hi
Please can anyone help I need to populate a combo box with the results returned froma stord Proc.
My code so FAR is
[vbcode]
Public Function ContactDetails()
Dim rsSet As ADODB.Recordset
Dim ObjCmd As Command
Set rsSet = New ADODB.Recordset
With rsSet
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.CursorType = adOpenDynamic
End With
Set ObjCmd = New Command
With ObjCmd
.ActiveConnection = gBass
.CommandType = adCmdStoredProc
.CommandText = "upSel_ContactDetails"
.Parameters.Append .CreateParameter("@AcNo", adVarChar, adParamInput,
40, AC_NO)
End With
Set rsSet = ObjCmd.Execute
CmboContact.RowSourceType = "value list"
CmboContact.RowSource = BuildComboList(rsSet)
End Function
Private Function BuildComboList(rs As ADODB.Recordset)
Dim OutStr As String
Do While Not rs.EOF()
OutStr = OutStr & """" & rs!AC_NO & """" & ";" & """" & rs!Contact_char &
"""" & ";"
rs.MoveNext
Loop
CmboContact = OutStr
End Function
[/vbcode]
Thanks for your help!!! :)
Re: Populating combo box with results from SP
Would this work for you?
Code:
Private Function BuildComboList(rs As ADODB.Recordset, cbo As Combobox)
Dim OutStr As String
Do While Not rs.EOF()
OutStr = OutStr & Chr(34) & rs!AC_NO & Chr(34) & ";" & Chr(34) & rs!Contact_char & Chr(34) & ";"
cbo.AddItem OutStr
rs.MoveNext
Loop
End Function
'usage:
BuildComboList rsSet, CmboContact
Re: Populating combo box with results from SP
Sorry it did not work..has anyone any other ideas??? :confused:
Re: Populating combo box with results from SP
What do you mean "it didn't work"? Any chance to see how you actually did it?
Please use CODE tags when posting your code. Thanks.