473,395 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Help with RecordCount Code

121 100+
I have a table [ETL_TBL]
and I want to do a count of the number of records where the field [ERR_DESC] is not Null


I have been trying to write a recordcount code. can anyone help me in how to write this. My specific problems are in writing the criteria.
Apr 19 '07 #1
6 2962
cmrhema
375 256MB
I have a table [ETL_TBL]
and I want to do a count of the number of records where the field [ERR_DESC] is not Null


I have been trying to write a recordcount code. can anyone help me in how to write this. My specific problems are in writing the criteria.

Try out this. I am assuming that you are using ADODB
[HTML]
If MyRs.State = adStateOpen Then MyRs.Close
'Myrs is the recordset
MyRs.CursorLocation = adUseClient
MyRs.Open "select count(*) from ETL_TBL where ERR_DESC IS NOT NULL", MyCon, adOpenDynamic, adLockOptimistic
'Mycon is the connection
Text1.Text = MyRs.Fields(0)[/HTML]

Good luck
Apr 19 '07 #2
I have a table [ETL_TBL]
and I want to do a count of the number of records where the field [ERR_DESC] is not Null


I have been trying to write a recordcount code. can anyone help me in how to write this. My specific problems are in writing the criteria.
Expand|Select|Wrap|Line Numbers
  1.   dim rsTemp as new ADODB.recordset
  2.   dim conntemp as new ADODb.Connection
  3.  ' set the Connection String to the Connection Object.
  4.  if rstemp.state=adstateopen then rstemp.close
  5.  rstemp.open"Select count(*) as cnt from ETL_TBL where ERR_DESC<>Null",contemp
  6.  
  7.  Msgbox"total Record=" & rstemp.fields("cnt").value
  8.  
Apr 19 '07 #3
JHNielson
121 100+
Expand|Select|Wrap|Line Numbers
  1.   dim rsTemp as new ADODB.recordset
  2.   dim conntemp as new ADODb.Connection
  3.  ' set the Connection String to the Connection Object.
  4.  if rstemp.state=adstateopen then rstemp.close
  5.  rstemp.open"Select count(*) as cnt from ETL_TBL where ERR_DESC<>Null",contemp
  6.  
  7.  Msgbox"total Record=" & rstemp.fields("cnt").value
  8.  
Thanks for everyone's great help.

I tried this code:
Expand|Select|Wrap|Line Numbers
  1. Function REC_COUNT_TEST_2()
  2.  
  3.   Dim rsTemp As New ADODb.Recordset
  4.   Dim conntemp As New ADODb.Connection
  5.  ' set the Connection String to the Connection Object.
  6.  If rsTemp.State = adStateOpen Then rsTemp.Close
  7.  rsTemp.Open "select count(*) from ETL_TBL where ERR_DESC IS NOT NULL", MyCon, adOpenDynamic, adLockOptimistic
  8.  
  9.  MsgBox "total Record=" & rsTemp.Fields("cnt").Value
  10.  
  11. End Function
  12.  
But it gives me an error:

'Arguments are of the wrong type, are out of acceptable range, or are in conflict with another"

Any ideas?

again, thanks os much
Apr 19 '07 #4
Killer42
8,435 Expert 8TB
What is the field type of field ERR_DESC? Text?

Also, just in case we're overlooking something, which line produces the error?
Apr 20 '07 #5
JHNielson
121 100+
What is the field type of field ERR_DESC? Text?

Also, just in case we're overlooking something, which line produces the error?

Yes, it is a text field
Apr 20 '07 #6
Thanks for everyone's great help.

I tried this code:
Expand|Select|Wrap|Line Numbers
  1. Function REC_COUNT_TEST_2()
  2.  
  3.   Dim rsTemp As New ADODb.Recordset
  4.   Dim conntemp As New ADODb.Connection
  5.  ' set the Connection String to the Connection Object.
  6.  If rsTemp.State = adStateOpen Then rsTemp.Close
  7.  rsTemp.Open "select count(*) from ETL_TBL where ERR_DESC IS NOT NULL", MyCon, adOpenDynamic, adLockOptimistic
  8.  
  9.  MsgBox "total Record=" & rsTemp.Fields("cnt").Value
  10.  
  11. End Function
  12.  

But it gives me an error:

'Arguments are of the wrong type, are out of acceptable range, or are in conflict with another"

Any ideas?

again, thanks os much
hi,
you use the code
Expand|Select|Wrap|Line Numbers
  1. rsTemp.Open "select count(*) from ETL_TBL where ERR_DESC IS NOT NULL", MyCon, adOpenDynamic, adLockOptimistic
  2.  
Again u use the code
Expand|Select|Wrap|Line Numbers
  1. MsgBox "total Record=" & rsTemp.Fields("cnt").Value
  2.  
Now U tell me where is the "cnt" field???--->thats the error
just use
Expand|Select|Wrap|Line Numbers
  1. MsgBox "total Record=" & rsTemp.Fields(0).Value
  2.  
check it. good luck.
Apr 20 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jules | last post by:
Is anyone able to translate the following PHP to ASP ? or come up with something that would work. The reason for the code is that I'm using Indexing service to create a search engine on a...
6
by: Mark Watkins | last post by:
I know for a fact that in my database, I have three records under the users table. However when I execute this code: --------------BEGIN CODE---------------- Set objConn =...
2
by: Phil Powell | last post by:
I am not sure why this is producing a SQL Server related error, but w/o having an instance of SQL Server on my machine to verify anything further, can you all help me with this? <!--- validate()...
4
by: Martin Franklin | last post by:
I am trying to get a total record count on a Acess 97 mdb database. However I get the following error when I try to load the page: Provider error '80040154' Class not registered...
12
by: scott | last post by:
In LISTING 2, I have a SPROC that returns a recordset and a recordcount in SQL QA. I can access the Recordset with no problem. How can I grab the Recordcount with ASP code at the same time I'm...
9
by: tym | last post by:
HELP!!! I'm going round the twist with this... I have a VB6 application which is using DAO to access a database (Please - no lectures on ADO, I know what I'm doing with DAO!!) Ok, problem...
3
by: kev | last post by:
Hello, I posted a question a while ago on tabbed pages, how to set it to invisible when the text box is empty.It was answered by Rick and the code ran perfectly. However, i tried using the same...
11
by: troy_lee | last post by:
I have two fields on a form. These two fields' values are based on an expression and represent a date range. I need to create a SQL statement that will use the returned values of these two fields...
0
by: timber910 | last post by:
Ok, I have a button on a form that I'm using to create another table I will need later in my form. I have created a reference table called Ref_Table (holds my table names - using this as the tables...
1
by: Orbie | last post by:
Hi All, I'm new to VB.NET and i'm looking for some help with my Windows Form. I need to check if a Commodity entered into (TextBox1.Text) already exists on my table before i insert it. I'm having...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.