Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 6th, 2004, 08:36 PM
SoC SoC is offline
Authorized User
 
Join Date: Jul 2004
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
Default If then ... for database records/web page

Hi,

I have a series of web pages that allow users to search an Access database.

One of the fields in this database contains URLs (in text format).

On my web page, I do not display the URL (because it is very long), but rather a graphic. Uses click the graphic and go to that URL.

Here's my question:

Not all records in the db currently include a URL. I would like to be able to show when a record does not have a URL by displaying a different graphic.

So when there is a URL, I display graphic 1, when there isn't a URL I display graphic 2.

I know it must be a fairly simple if statement, but I'm not sure how to do it.

Here's my code:
Code:
<td width="10" align="center" valign="top">
<a href="http://myWeb/documents/<%=(rsDirected.Fields.Item("url").Value)%>">
<img src="images/doc-link.gif" alt="Click to Open Document"</a>
So really I just need something that says

if rsDirected.Fields.Item.Value = null then
display pic 2
else
display pic 1
end if

thanks
S

 
Old September 7th, 2004, 08:36 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there.. you have it rigth.. you need something like you say..
can you just read the value of the item before construct the page?? you will have to construct it iterating around all the records...

HTH

Gonzalo
 
Old September 9th, 2004, 02:10 AM
SoC SoC is offline
Authorized User
 
Join Date: Jul 2004
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, I worked out how to do it:

<a href="http://myweb/mypage/<%=(myRecordSet.Fields.Item("url").Value)%>">
<%if myRecordSet.Fields.Item("url").Value = "" then%>
<img src="images/image1.gif" alt="image 1 alt text">
<%else%>
<img src="images/image2.gif" alt="image 2 alt text">
<%end if%>

Had to make sure that the database had zero length strings ("") inserted, not nulls. Also tried putting in a value in place of ero length string (a page name, let's say default.htm)

All works very well.

cheers






Similar Threads
Thread Thread Starter Forum Replies Last Post
how to prevent a web page/window page from copying pradeeppatnaik81 C# 2 April 9th, 2008 03:36 AM
How to diplay web page inside another web page win cyberjoe C# 2 March 1st, 2007 05:35 AM
How to retrieve a web page from access database method Access ASP 1 May 2nd, 2005 06:29 PM
First page has fewer records jmurdock BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 1 June 28th, 2004 02:47 PM
Multiple records on same page mossimo Classic ASP Databases 10 December 4th, 2003 05:51 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.