473,396 Members | 1,963 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,396 software developers and data experts.

using recordcount and not getting what is in the table

Is recordcount a little messed or what?

For Each tdf In dbs.TableDefs
If Left(tdf.Name, 3) = "tbl" Then
Debug.Print tdf.Name
Debug.Print tdf.RecordCount

it prints the correct name but the RecordCount is off on 8 out of 30
tables. the only thing is all the correct ones don't have any records
LOL

3 of the 8 show 20 records but the tables contain 21
2 or the 8 show 12 when they have 15
3 or the 8 show 17 when they have 18

what am I doing wrong?
Sep 18 '08 #1
3 11041
sparks wrote:
Is recordcount a little messed or what?

For Each tdf In dbs.TableDefs
If Left(tdf.Name, 3) = "tbl" Then
Debug.Print tdf.Name
Debug.Print tdf.RecordCount

it prints the correct name but the RecordCount is off on 8 out of 30
tables. the only thing is all the correct ones don't have any records
LOL

3 of the 8 show 20 records but the tables contain 21
2 or the 8 show 12 when they have 15
3 or the 8 show 17 when they have 18

what am I doing wrong?

Try this, see if it works better
Dim tdf As TableDef
Dim dbs As Database
Set dbs = CurrentDb
Dim rst As DAO.Recordset

For Each tdf In dbs.TableDefs
If Left(tdf.Name, 3) = "tbl" Then
Set rst = dbs.OpenRecordset(tdf.name, dbOpenSnapshot)
If rst.RecordCount 0 Then rst.MoveLast
Debug.Print tdf.name; rst.RecordCount
rst.Close
End If
Next
Set rst = Nothing
Set dbs = Nothing
Sep 18 '08 #2
On Thu, 18 Sep 2008 11:35:34 -0700, Salad <oi*@vinegar.comwrote:
Dim tdf As TableDef
Dim dbs As Database
Set dbs = CurrentDb
Dim rst As DAO.Recordset

For Each tdf In dbs.TableDefs
If Left(tdf.Name, 3) = "tbl" Then
Set rst = dbs.OpenRecordset(tdf.name, dbOpenSnapshot)
If rst.RecordCount 0 Then rst.MoveLast
Debug.Print tdf.name; rst.RecordCount
rst.Close
End If
Next
Set rst = Nothing
Set dbs = Nothing
at first I thought it was the the rst.movelast that would make it
work.
I thought that the movelast would make sure that everything was loaded
before it printed the count.

but that did not make a difference.

It was the dbOpenSnapshot that did it.

I had tried dbOpenTable and dbOpenDynaset and both gave the same
results.

thank you very much for your help it was driving me nuts....I am just
glad I looked and didn't take it as it was....

thanks again

Sep 18 '08 #3
sparks wrote:
On Thu, 18 Sep 2008 11:35:34 -0700, Salad <oi*@vinegar.comwrote:

> Dim tdf As TableDef
Dim dbs As Database
Set dbs = CurrentDb
Dim rst As DAO.Recordset

For Each tdf In dbs.TableDefs
If Left(tdf.Name, 3) = "tbl" Then
Set rst = dbs.OpenRecordset(tdf.name, dbOpenSnapshot)
If rst.RecordCount 0 Then rst.MoveLast
Debug.Print tdf.name; rst.RecordCount
rst.Close
End If
Next
Set rst = Nothing
Set dbs = Nothing


at first I thought it was the the rst.movelast that would make it
work.
I thought that the movelast would make sure that everything was loaded
before it printed the count.

but that did not make a difference.

It was the dbOpenSnapshot that did it.

I had tried dbOpenTable and dbOpenDynaset and both gave the same
results.
How odd!
thank you very much for your help it was driving me nuts....I am just
glad I looked and didn't take it as it was....

thanks again
Entirely welcome.
Sep 18 '08 #4

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

Similar topics

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...
3
by: MikeR | last post by:
When I use the following, the RS.recordcount is -1. I also can't do a RS.moveprevious. What have I overlooked? Thanks, Mike dbname="DBQ=" & Server.MapPath("../db/my.mdb") set...
5
by: Ilan Sebba | last post by:
When it comes to adding records in related tables, Access is really smart. But when I try to do the same using ADO, I am really stupid. Say I have two parent tables (eg Course, Student) and one...
2
by: kai | last post by:
Hi, All I used to link a SQL Server 2000 table through ODBC in Access 2003 using Wizard, now because the security requirement, I want to do the same job using code. I tried hard, but not...
4
by: C White | last post by:
Hi I am having problems with running a query that does the following there are 5 fields in a table that the query is based on, the first four are simple enough and all that happens is that the...
16
by: Ian Davies | last post by:
Hello Needing help with a suitable solution. I have extracted records into a table under three columns 'category', 'comment' and share (the category column also holds the index no of the record...
2
by: ChasW | last post by:
I am trying to get a correct recordcount from a recordset that references a linked table as the source. Here is the code: Dim db1 As DAO.Database Dim rs1 As DAO. Recordset Set db1 =...
1
by: anniefs | last post by:
hi help me i m so much stuck int he code and i have no time .... i used ASP VBscipt and javascript functions with MS database javascript function add records in MS DB by using ASP vbscript...
3
ADezii
by: ADezii | last post by:
Last Tip, we demonstrated the technique for retrieving data from a DAO Recordset, and placing it into a 2-dimensional Array using the GetRows() Method. This week, we will cover the same exact Method...
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.