LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default VBA & SQL

There is a detail that makes that a little difficult...

The ListBox is MultiSelection enabled, so in the SQL Statement the WHERE
clause should be using the IN verb instead of equal to... how to do this? I'm
getting an error message because don't know how to use the '(' properly in
the statement.

Thanks!

"dmoney" wrote:

Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strsql As String
Dim dbase As String
Dim listbox as string

dbase = "WhatIf" 'this is the catalog name on your sql server
listbox = listbox1.value

cn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist
Security Info=False;" _
& "Initial Catalog='" & dbase & "';Data
Source=xxserverxx"
cn.Open
cn.CursorLocation = adUseClient

If OptionButton1.Value = True Then

strsql = "SELECT EAC FROM vblFccaSummary " _
& "WHERE xxdatabasefieldxx= '" & listbox & "'


"Excel interacting dinamically to SQL Srv" wrote:

Hi folks,

I have a spreadsheet that queries a SQL Server. I would like to use the
values selected on some form controls as parameters to my queries. Eg: I will
query the server using in the where clause the values selected in a specific
listbox from the spreadsheet... the results will be showed in the same
spreadsheet in a destination pre-defined.

Did anybody do this before? Any hint or tip to help me?

Many thanks in advance and congratulations to every contributor that help to
make this community a high-level information source!

Leandro - BR

 
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



All times are GMT +1. The time now is 02:22 PM.

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

About Us

"It's about Microsoft Excel"