LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default ado connection sql script select via listbox

Dear All

I have been struggling with this problem for a while now and need
assistance. I have two list boxs. One with a list of customer id's and I want
the user to select the custid and the second list box to display the addres
information. I have the following code already and it just doesnt work.
Please help

Dim cnn1 As New ADODB.Connection
Dim rst1 As New ADODB.Recordset

cnn1.Open "PROVIDER=SQLOLEDB;" & _
"Server=XXXXXXXX;INITIAL CATALOG=XXXX;Integrated
Security=sspi"
rst1.Open "SELECT CUSTNAME, Address1, address2, City FROM RM00101 where
custnmbr in ('" & ListBox1.Value & "') ;", _
cnn1, adOpenStatic
rst1.MoveFirst
With Me.ListBox2
.Clear
Do
.AddItem rst1![Custnmbr]
.AddItem rst1![CUSTname]
.AddItem rst1![Address1]
.AddItem rst1![Address2]
.AddItem rst1![City]
rst1.MoveNext
Loop Until rst1.EOF
End With
 
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
Double click item in Listbox to select item and close Listbox GusEvans Excel Programming 3 July 19th 07 12:36 PM
Select a ListBox value with code Riddler Excel Programming 0 November 20th 06 04:21 PM
Listbox Multi Select MikeT Excel Programming 2 July 27th 06 08:25 PM
I need to select some values in a Listbox???? Angel[_3_] Excel Programming 0 January 22nd 04 02:26 PM
Select from table and listbox PawelR Excel Programming 1 November 7th 03 01:21 PM


All times are GMT +1. The time now is 11:38 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"