Loading combobox and subsequent textbox from SQL stored procedure

NickySummers

New Member
Joined
Jul 25, 2014
Messages
1
Hi,
I've have the code below to fill a combobox with data from a mySQL stored procedure. The SP selects the customer code and customer name. Depending on what customer code the user chooses, I need to populate a textbox with the associated customer name. Please could somebody help me with the best way to do this?
Thanks very much.

Dim Conn As ADODB.Connection
Dim ConnectionString As String
Dim cmd As ADODB.Command
Dim fld As Variant
Dim Results As ADODB.Recordset
Dim x As Integer
Dim vaData As Variant




'ConnectionString = "Provider=MSDASQL.1;Driver={SQL Server};Server=TestVSQL01\TestSQL01;Database=OptimusBridge;Uid=delta_web_test;Pwd=delta_web_test"
ConnectionString = "Provider=MSDASQL.1;Driver={SQL Server};Server=BI-BRIDGE\SQLExpress;Database=OptimusBridge;Uid=workstream;Pwd=workstream"


Set Conn = New ADODB.Connection


Conn.Open ConnectionString






Set cmd = New ADODB.Command
With cmd
.CommandText = "GetAllClients"
.CommandType = adCmdStoredProc
.ActiveConnection = Conn
End With


Set Results = cmd.Execute


With Results
x = .Fields.Count
vaData = .GetRows
End With


With frmDataInput
With .cboClient
.BoundColumn = x
.List = Application.Transpose(vaData)
.ListIndex = -1
End With
.Show vbModeless
End With


Results.Close
Set Results = Nothing
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Forum statistics

Threads
1,223,238
Messages
6,170,939
Members
452,368
Latest member
jayp2104

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top