473,480 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Recordset Empty Error

Hi All

Does anyone know why the code below gives me an error on the line
strTt = FormatNumber( RS("Expr1") , 2)

whenever RS is empty.

Am I doing something wrong?

<%
SQL = " SELECT Sum(PODetails.Amount) AS Expr1 FROM PODetails where PONumber=
" & rstDBEdit.Fields("PONumber").Value

Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open SQL, CONN_STRING

if not rs.eof then
strTt = FormatNumber( RS("Expr1") , 2)
else
strTT= 0.00
strTT = FormatNumber( strTT , 2)
end if
Response.write strTT

%>
Jul 19 '05 #1
4 2081
whats the error?
"J P Singh" <noemail@asIhatespam> wrote in message
news:Of**************@TK2MSFTNGP10.phx.gbl...
Hi All

Does anyone know why the code below gives me an error on the line
strTt = FormatNumber( RS("Expr1") , 2)

whenever RS is empty.

Am I doing something wrong?

<%
SQL = " SELECT Sum(PODetails.Amount) AS Expr1 FROM PODetails where PONumber= " & rstDBEdit.Fields("PONumber").Value

Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open SQL, CONN_STRING

if not rs.eof then
strTt = FormatNumber( RS("Expr1") , 2)
else
strTT= 0.00
strTT = FormatNumber( strTT , 2)
end if
Response.write strTT

%>

Jul 19 '05 #2
Hi Alex

Microsoft VBScript runtime error '800a000d'
Type mismatch: 'FormatNumber'

/request1.asp, line 727

"Alex Goodey" <ag*****@hsfinancial.co.uk> wrote in message
news:bu************@ID-221525.news.uni-berlin.de...
whats the error?
"J P Singh" <noemail@asIhatespam> wrote in message
news:Of**************@TK2MSFTNGP10.phx.gbl...
Hi All

Does anyone know why the code below gives me an error on the line
strTt = FormatNumber( RS("Expr1") , 2)

whenever RS is empty.

Am I doing something wrong?

<%
SQL = " SELECT Sum(PODetails.Amount) AS Expr1 FROM PODetails where

PONumber=
" & rstDBEdit.Fields("PONumber").Value

Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open SQL, CONN_STRING

if not rs.eof then
strTt = FormatNumber( RS("Expr1") , 2)
else
strTT= 0.00
strTT = FormatNumber( strTT , 2)
end if
Response.write strTT

%>


Jul 19 '05 #3
Because if it's empty, it can't format it to a number.

Dim theVal
theVal=RS.Fields("Expr1").Value 'may want to change Expr1 to something a
little more helpful
if isNumeric(theVal) then
strTt=FormatNumber(theVal,2)
else
strTt="0.00" 'or whatever else the default should be.
end if
There's an FAQ at www.aspfaq.com about the isNumeric function - which you
may wish to review.
"J P Singh" <noemail@asIhatespam> wrote in message
news:Of**************@TK2MSFTNGP10.phx.gbl...
Hi All

Does anyone know why the code below gives me an error on the line
strTt = FormatNumber( RS("Expr1") , 2)

whenever RS is empty.

Am I doing something wrong?

<%
SQL = " SELECT Sum(PODetails.Amount) AS Expr1 FROM PODetails where PONumber= " & rstDBEdit.Fields("PONumber").Value

Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open SQL, CONN_STRING

if not rs.eof then
strTt = FormatNumber( RS("Expr1") , 2)
else
strTT= 0.00
strTT = FormatNumber( strTT , 2)
end if
Response.write strTT

%>

Jul 19 '05 #4
Top Man

Works like a charm
"TomB" <sh*****@hotmailXXX.com> wrote in message
news:eG*************@tk2msftngp13.phx.gbl...
Because if it's empty, it can't format it to a number.

Dim theVal
theVal=RS.Fields("Expr1").Value 'may want to change Expr1 to something a
little more helpful
if isNumeric(theVal) then
strTt=FormatNumber(theVal,2)
else
strTt="0.00" 'or whatever else the default should be.
end if
There's an FAQ at www.aspfaq.com about the isNumeric function - which you
may wish to review.
"J P Singh" <noemail@asIhatespam> wrote in message
news:Of**************@TK2MSFTNGP10.phx.gbl...
Hi All

Does anyone know why the code below gives me an error on the line
strTt = FormatNumber( RS("Expr1") , 2)

whenever RS is empty.

Am I doing something wrong?

<%
SQL = " SELECT Sum(PODetails.Amount) AS Expr1 FROM PODetails where

PONumber=
" & rstDBEdit.Fields("PONumber").Value

Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open SQL, CONN_STRING

if not rs.eof then
strTt = FormatNumber( RS("Expr1") , 2)
else
strTT= 0.00
strTT = FormatNumber( strTT , 2)
end if
Response.write strTT

%>


Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5305
by: Eli Sidwell | last post by:
Trying to return a Recordset to an ASP and the Recordset is empty. The StorredProc works in the query analyzer and it even works from a quick VB app that I wrote to test it. The storedproc that...
1
3965
by: Filips Benoit | last post by:
Dear All, (No aswers on access newsgroups) Access2000.adp connected to SQL-server 2000 MainForm unbound: seachform on companies meeting a complex combination of criteria. SubFrom and ListBox...
7
8483
by: Jean | last post by:
Hello, I have a form that performs a search, according to criteria that a user enters into the text boxes. When the user clicks on „Search", a SQL string (say strSQL) is built up with the...
36
4411
by: kjvt | last post by:
Based on a prior posting, I've written a function to convert a recordset to a dataview. The first call to the function for a given recordset works perfectly, but the second call always returns a...
5
3978
by: jonman | last post by:
Hello, I'm a bit of a newbie when it comes to Access (and DB's in general). I've got a form that allows the assembles a SQL string (that I've tested interactively, and proven that it returns...
23
52582
by: PW | last post by:
Hi, I'd like to close a recordset and set the database to nothing if a recordset is open if an error has occured. Leaving a recordset open and a database open isn't a good idea, right? ...
0
24841
ADezii
by: ADezii | last post by:
When you create a Recordset, you may want to know immediately whether that Recordset actually contains any Rows. There are Recordsets that don't return any Rows and you may need to take different...
2
2336
by: hackmagic | last post by:
Hi, i have a form that normally has a Recordset containing only one record bound to it. i have replaced the navigation buttons with my own and the 'New Record' button assigns an empty Recordset...
4
2574
by: ipez75 | last post by:
Hello everyone, I have a web application written in asp 6.0, my problem is that I execute a sql server store procedure and I get an empty recordset, while executing the same sp on query anlyzer I...
2
5494
by: wallconor | last post by:
Hi, I am having a problem using Dreamweaver CS3 standard recordset paging behavior. It doesn’t seem to work when I pass parameter values from a FORM on my search page, to the recordset on my...
0
7041
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7044
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7084
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6739
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5337
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4779
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
2995
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2984
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
181
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.