Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - ASP Combo Box
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

ASP Combo Box

 Post Reply Post Reply
Author
KenW View Drop Down
Newbie
Newbie
Avatar

Joined: 29 June 2004
Location: United Kingdom
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote KenW Quote  Post ReplyReply Direct Link To This Post Topic: ASP Combo Box
    Posted: 05 December 2004 at 1:26pm
I have a form which populates a combo box from an  access 2000 database see code below.
It works fine with no problems however I would like to insert some code which would redirect the user if the database is empty.
I have tried the following code
If  lstviewpages = "" Then Response.Redirect "pages_index.asp?select=ID No Messages"
in various places but even when the database is full it still redirects the user.
any help would be most welcome
Regards
Ken

<form method="get" action="Ken_view.asp"><p>
<%
Dim objPagesview, lstviewpages
Set objPagesview = Server.CreateObject("ADODB.Recordset")
objPagesview.ActiveConnection = DSNtemp
objPagesview.Open "tblKen"
objPagesview.movefirst
%>
<select class=
"smltext" name="lstviewpages" size="1">
<%
Do while not objPagesview.EOF
response.write "<option value='" & objPagesview("delID") & "'>"
response.write objPagesview("MessageTitle") & "</option>"
objPagesview.movenext
loop
objPagesview.close
set objPagesview=nothing
%>
</select></p><BR>
<p><input type=
"submit" class="smltext" style="width: 10em; height: 2.2em; margin: 0 0 3 0" VALUE="View Message"></p>
</form>

Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post Posted: 05 December 2004 at 1:29pm
Right after:

objPagesview.Open "tblKen"

Do:

If objPagesview.EOF then
    'Close all your objects here
    'Redirect user
End if

Back to Top
KenW View Drop Down
Newbie
Newbie
Avatar

Joined: 29 June 2004
Location: United Kingdom
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote KenW Quote  Post ReplyReply Direct Link To This Post Posted: 05 December 2004 at 4:11pm
Hi
Gullanian
I tried out your code but it just keeps asking me for a loop serveral hundred lines down the page?
This is the code I used am I missing something?
(The inserted code is in red)
Regards
Ken

<table width="75%" border="0" cellspacing="0" cellpadding="0" align="center">
 
<tr>
   
<td align="center" class="text">Please select a Message to View / Print.</td>

 
</tr>
 
<tr>
   
<td align="center" class="text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>

 
</tr>
 
<tr>

Back to Top
KenW View Drop Down
Newbie
Newbie
Avatar

Joined: 29 June 2004
Location: United Kingdom
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote KenW Quote  Post ReplyReply Direct Link To This Post Posted: 07 December 2004 at 5:02pm
Hi
Gullanian
I now have it working I took a different approach the inserted code is in red. Thanks for your help.
Regards
Ken
 
<form method="get" action="Ken_print.asp"><p>
<%
Dim objPagesview, lstviewpages
Set objPagesview = Server.CreateObject("ADODB.Recordset")
objPagesview.ActiveConnection = DSNtemp
objPagesview.Open "tblKen"
IF objPagesview.EOF THEN

Response.Write "<table width=""80%"" align=""center"" border=""0"">"%>
<tr>
<td align="center" class="text">There are no messages in your Inbox.</td></tr>
<tr><td align="center">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr>
<tr><td align="center" class="text">Please try again later.</td></tr>
<tr><td align="center">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr>
<% Response.Write "</table>"
ELSE

objPagesview.movefirst
%>
<select class=
"smltext" name="lstmainpage" size="1">
<%
Do while not objPagesview.EOF
response.write "<option value='" & objPagesview("delID") & "'>"
response.write objPagesview("MessageTitle") & "</option>"
objPagesview.movenext
loop
objPagesview.close
set objPagesview=nothing
%>
</select></p>
<p><input type=
"submit" class="smltext" style="width: 12em; height: 2.2em; margin: 0 0 3 0" VALUE="Read / Print Message"></p>
</form>
</td>
</tr>
</table>
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.