CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Showing a hyperlink if another value exists?

Print topic Send  topic

Author Message
brandx


Posts: 29
Posted: 10/30/2005, 5:39 PM

Ok.... this may get confusing..... :-/

Codecharge studio 2.3.1.85
ASP / Access

There are two tables, one called "users" the other called "listings"

I've created a grid that lists all the users "users.asp"

What i need to happen is.....

If the user has any listings in the "listings" table, a hyperlink should be visible on the user.asp page along with their listing that links to another page to display that listing information. If the user has no listings in the "listings" table, no hyperlink should appear.

The primary field in the "users" table is "user_id". This "user_id" would also be in any of the listing the've submitted.

I have no idea how to make this hyperlink dynamically appear based on if they have any records in the "listings" table.

Any assistance would be appreciated.

Cheers,
Geary
View profile  Send private message
Edd


Posts: 547
Posted: 10/30/2005, 6:15 PM

Geary,
This is a common issue and can be solved through a couple of pieces of code.

Firstly in the UsersGrid, you need to determine if there are any records in the listings table, therefore I suggest the following:
1. Change your grid to SQL
2. In the SQL add an SQL sub-select detailing the number of listings available e.g.
Select User.UserID, User.UserName, (select Count(*) from Listings where Listings.UserID = User.UserID) as NoOfListings from User

You then have a count of whether a item has a link or not.

Now you can go back to the grid and select the field that you want to hyperlink from, for this case we select UserID.
1. Change it's output format to HTML
2. Add a beforeshow event.

In the event
Dim UserID
Dim StrHTML

UserID= TheNameOfMyGrid.UserID.value
NoOfListings = TheNameOfMyGrid.DataSource.RecordSet.fields("NoOfListings")

If NoOfListings = 0 Then
StrHTML = CStr(UserID)
Else
StrHTML = "<a href=""NameofListingPage.asp?UserID=" & CStr(UserID) & "">" & CStr(UserID) & "</a>"
End If

UserID.value = StrHTML

----------------------------------
I could have done a lookup test at the each value but that slows the application considerably and should be avoided where possible in things such as grids.

Edd
_________________
Accepting and instigating change are life's challenges.

http://www.syntech.com.au
View profile  Send private message
brandx


Posts: 29
Posted: 10/30/2005, 7:23 PM

Thank you Edd :) :)

Did run into a small issue with the userid field being an integer... but that was all fixed after changing it to text.

It's working perfectly !

Cheers,
Geary
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.