Solved

Display all when first selection is made on drop down menu

Posted on 2013-12-14
5
267 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Two wordpress questions 3 45
Query Syntax 17 36
Jquery Check against database on select from auto fill not working in all browsers 5 31
Hide cell in a table 2 14
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

777 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