Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Display all when first selection is made on drop down menu

Posted on 2013-12-14
5
270 Views
Last Modified: 2013-12-19
I am using SQL, ASP classic and VBscript on my results page.

On the search page I have a drop down menu listing a list of clients, it displays the name of the client and passes on the ID of the client to page # 2

The query on page # 2 filters out using the ID.

I am using Dreamweaver to create my recordsets.

The sql reads:  Select * from table where  b.userid = MMColParam11

The first item of the list of clients says "All clients", which is manually entered, the rest come from a recordset and all have names and ID's.

When I filter text fields I can use the '%' to get all records for "All" or when no selection is made, in this case they are integer numbers, I get an error if I use % ... is there a way alternative to pass a value that will return ALL records like when comparing a text ?
0
Comment
Question by:amucinobluedot
  • 3
  • 2
5 Comments
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 500 total points
ID: 39719207
Hi,

I think you have either to change the query in a way to use something like
Select * from table where  b.userid > MMColParam11

Open in new window

passing the value 0 to MMColParam11
OR
you change the query like
Select * from table where  b.userid = MMColParam11 OR 1=1

Open in new window

adding a condition which is always true.

HTH
Rainer
0
 

Author Comment

by:amucinobluedot
ID: 39719237
I pass 0 then great, all come up, but if I pass a value like 120, then instead of just getting 120, I get 120 and any other ID above 120 correct ?... that won't work.

It was to be the ID that is selected and if none then ALL.

I can pass '0' and if that is the case I would need to return all ... can this be done as a condition ?

if MMColParam11 = 0 then (no requirement to match b.userid),
if MMColParam11 <>) then 'WHERE b.userid = MMColParam11

Just an idea but I am not sure if that can be done in a query.
0
 
LVL 44

Assisted Solution

by:Rainer Jeschor
Rainer Jeschor earned 500 total points
ID: 39719251
Hi,
I meant that in your code where you create your query, you use something like
yourSelectQuery = "Select * from table where  b.userid"
If MMColParam11 = 0 Then
  yourSelectQuery = yourSelectQuery  & ">0"
Else
  yourSelectQuery = yourSelectQuery  & "=" & MMColParam11
End If

Open in new window


This will return everything if the value is 0 OR it returns the provided userid

HTH
Rainer
0
 

Author Comment

by:amucinobluedot
ID: 39719263
1=1 won't work, if I make a selection and an ID is passed it displays ALL results. This should ONLY happen if MMColParam11 is '0', which is the default value when nothing is passed
0
 

Author Closing Comment

by:amucinobluedot
ID: 39729794
:)
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Format Data Field - SQL 11 37
Diminish Pop-up  in 3 seconds 7 49
table joins in qry 17 61
Query for timesheet application 3 18
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
The viewer will learn how to count occurrences of each item in an array.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question