help with code!

A

AAA

Hello!

The scenario:

I have a .asp page that contains a form with a database
results component. The database result is a query that
will return cercain amount of records from an access
database.

The question:

How can I make the form to show different buttons
depending on the amount of records returned by the query?
In other words, if the query returns no records I need to
show BUTTON_A; if the query returns 1 record I need to
show BUTTON_B; if the query returns 2 records I need to
show BUTTON_C and so on...
The actions associated with each button should be
different, lets say each button redirects the user to a
different page.

Please help!!

Thanks in advance.
 
J

Jim Buyens

-----Original Message-----
Hello!
Howdy.

The scenario:

I have a .asp page that contains a form with a database
results component. The database result is a query that
will return cercain amount of records from an access
database.

The question:

How can I make the form to show different buttons
depending on the amount of records returned by the query?
In other words, if the query returns no records I need to
show BUTTON_A; if the query returns 1 record I need to
show BUTTON_B; if the query returns 2 records I need to
show BUTTON_C and so on...
The actions associated with each button should be
different, lets say each button redirects the user to a
different page.

This is going to be ugly. You're perilously close to the
point where it would be easier to learn how to do this
properly in ASP or ASP.NET than to "trick" the DRW into
doing it. However:

1. Add a second DRW to your page.
2. Configure it to use a custom query like this:

SELECT switch(
Count(*) < 1,
'<input type=button onclick=window.location.href=pg0.htm>',
Count(*) = 1,
'<input type=button onclick=window.location.href=pg1.htm>',
Count(*) > 1,
'<input type=button onclick=window.location.href=pg2.htm>'
) AS buttons
FROM yourtable
WHERE (yourtable.yourfield = 'whatever')

where the FROM and WHERE clauses are the same as your
existing query.
Note that inside the switch() function:
- the first parameter is a true/false condition.
- the second parameter is the result if the first
parameter is true.
- the third parameter is a true/false condition.
- the fourth parameter is the result if the third
parameter is true.
- and so forth.

3. Configure it not to display column headings or
next and back buttons.

To display the results as HTML, right-click the buttons
column in the finished Database Results Region, choose
Dababase Column Value Properties, and select Column Value
Contains HTML.

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top