Passing Parameters from A Multiple Select Drop Down Box

  • Thread starter Thread starter Jeff Thur
  • Start date Start date
J

Jeff Thur

How can I select multiple States from the drop down box
and pass them on to my SQL Query.

Thanks for any help in advance.
 
Hi Jeff,

You're running up against a well known sql problem - the inability to pass
an array to sql server - or, rather, the difficulty, because it can be done
(in effect) in certain convoluted ways.

Here's probably the easiest way to do something like this, and a routine I
use all the time:
create an array or arraylist of the states - New York, Oregon, Florida - and
convert them to a comma and apostrophe delimited file, like this (here I use
the contents of a datatable, but I often also use an arraylist or array as
the value source):

Dim longstring As String

longstring = "('"

Dim irow As DataRow

For Each irow In dshistory.Tables(0).Rows

longstring = longstring & Trim(irow("imcacct")) & "','"

Next

longstring = Mid(longstring, 1, longstring.Length - 2) & ")"

The call your select:

select * from ttable where acctnum in " & longstring

HTH,

Bernie Yaeger
 
Back
Top