|
| |
|
|
liz_611
Posts: 14 From: new york, ny Status: offline
|
Two variables, One parameter - 11/5/2001 17:44:00
I'm not sure this is the place to ask this question but you folks have always been helpful!I'm using Access as my db. I've got a query that I want to pass a parameter to. I use a multiselect dropdown list to get the the users choices to pass. The problem is that I can only figure out how to pass one variable at a time. So let's say the user chooses Albany and Atlanta. I want both of them to be passed to the parameter City. objComm.Parameters("Required City") = strCity This is the string I'm using. I've tried the following: "Albany" or "Atlanta", "Albany", "Atlanta" and a bunch of others but none seem to work. Any ideas??
|
|
|
|
Spooky
Posts: 26617 Joined: 11/11/1998 From: Middle Earth Status: offline
|
RE: Two variables, One parameter - 11/5/2001 20:18:00
When a user selects options from a multiselect box, then the result is passed as a comma delimited string.So the actual value of strCity (assuming its request.form()) = "Albany,Atlanta" Now this is no good as a search string because of the comma. If the actual search field = "[cityname]" then you could do this : strCity = replace(strCity, "," , "','") strCity ="'" & strCity & "'" This will give 'Albany','Atlanta' Now, select * from table where city IN ("&strCity &")
OR -> select * from table where city IN ('Albany','Atlanta')
------------------ §þððk¥ "I am Spooky of Borg. Prepare to be assimilated, babycakes!" Subscribe to OutFront News Database / DRW Q & A The Spooky Login! VP-ASP Shopping cart
|
|
|
|
liz_611
Posts: 14 From: new york, ny Status: offline
|
RE: Two variables, One parameter - 11/5/2001 21:44:00
That works if I only have one query to deal with but what I've got are two queries. I have to create the first query with the parameter(s). Then I inner join the first query to the second so that I can create a single total record. To make this a little clearer: the first query has a record id and cities. The user can choose from 1 -20 cities. The second query then groups the records by type and creates a total for each type (there are 7 different types). I can't do this in one query because I'd get total records for each city/type. What I want is simply a total for each type. I created two SQL statements and then opened two recordsets. I can't seem to use an inner join on the two recordsets. Any ideas on where to go from here?
|
|
|
|
Spooky
Posts: 26617 Joined: 11/11/1998 From: Middle Earth Status: offline
|
RE: Two variables, One parameter - 11/6/2001 20:25:00
Something like this may work? It should give a count of each datatype based on the city input Otherwise, no Im not quite clear what you want  code:
Set objConn = Server.CreateObject("ADODB.Connection") objConn.Open strConn Set objRS = Server.CreateObject("ADODB.Recordset") objRS.Open "SELECT COUNT(*) as fldCount FROM Table WHERE Ctiy IN ("&strCity &") AND DataType in ('Option1', 'Option2','Option3','Option3',....) GROUP BY DataType ", objConn Do until objRS.EOF fldCount = fldCount & CInt(objRS(0)) & "," objRS.movenext Loop objRS.Close arrCombo = Split(fldCount,",") Option1 = Trim(arrCombo(0)) Option2 = Trim(arrCombo(1)) Option3 = Trim(arrCombo(2)) Option4 = Trim(arrCombo(3)) Option5 = Trim(arrCombo(4)) Option6 = Trim(arrCombo(5)).... etc
------------------ §þððk¥ "I am Spooky of Borg. Prepare to be assimilated, babycakes!" Subscribe to OutFront News Database / DRW Q & A The Spooky Login! VP-ASP Shopping cart
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|