Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Updating cell values on sheet based on selected combo box value

Hi all, I have a sub that populates a combo box based on a retreived
SQL Server 2000 value. This works fine, but I'm not sure how to go
about updating other controls or cells on the page based on this value.
So if the user selects a different order number in this case, different
values which correspond to this order number will appear. Here is my
sub, thanks in advance, Buster.

Public Sub PopulateControl()

Dim cnRetailData As ADODB.Connection
Dim rsRetailData As ADODB.Recordset
Dim strCnn As String

' Open connection.
strCnn = "Provider=sqloledb; Data Source=TEST;Initial
Catalog=TESTDB;" & _
"User Id=xx;Password=xxxxx; "
Set cnRetailData = New ADODB.Connection
cnRetailData.Open strCnn

' Open Orders table.
Set rsOrders = New ADODB.Recordset
rsOrders.CursorType = adOpenKeyset
rsOrders.LockType = adLockOptimistic
rsOrders.Open "Orders", cnRetailData, , , adCmdTable

' Moves to the first record in the record set.
rsOrders.MoveFirst

' Loops through each entry in the record set and adds the last name
' for each entry into the combo box.
Do Until rsOrders.EOF
ActiveSheet.ComboBox1.AddItem rsOrders!order_number
' To use a ListBox control, use the following statement instead
' of the one above:
' UserForm1.ListBox1.AddItem rsOrders!order_number
'
' If the ComboBox or ListBox is on a worksheet instead of
' a UserForm, reference the worksheet instead of the UserForm:
' ActiveSheet.ComboBox1.AddItem rsOrders!order_number
rsOrders.MoveNext
Loop

' Displays the user form. You don't need this if you are not using
' a UserForm object.
'UserForm1.Show

' Closes the table.
rsOrders.Close
' Closes the connection.
cnRetailData.Close

End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
List values based on different values selected maniarasan Excel Discussion (Misc queries) 7 June 4th 10 02:12 PM
Transferring Columns to another sheet based on Cell values Ian Excel Programming 0 August 31st 06 08:14 AM
Change the line color based on the value selected in combo box Avinash Excel Programming 1 July 5th 06 09:50 PM
Updating excel sheet with selected data from another sheet in the same file gsnivas Excel Worksheet Functions 1 August 4th 05 09:55 AM
Combo box values based on other combo box value JCanyoneer Excel Programming 1 April 5th 05 06:41 PM


All times are GMT +1. The time now is 04:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"