Solved

Display all when first selection is made on drop down menu

Posted on 2013-12-14
5
271 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
[X]
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
  • 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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Drop Down not working in mobile- Bootstrap 14 29
SQL Query help 3 24
Prevent certain words from being typed in a form 6 27
UPDATE JOIN multiple tables 5 19
When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will learn how to count occurrences of each item in an array.

756 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