PC Review


Reply
Thread Tools Rate Thread

VBA Table Record Count

 
 
=?Utf-8?B?RGF2aWQgV2lkZW5lcg==?=
Guest
Posts: n/a
 
      26th Jan 2005
Is there an easy way to count the records in a table without opening the
table and counting each record some sort of a listfile function the gives you
a count ???, any help would be appreciated.


 
Reply With Quote
 
 
 
 
Lynn Trapp
Guest
Posts: n/a
 
      26th Jan 2005
Create a saved query that pulls all the records from your table and then
call the following function.

Public Function GetRecordCount()
Dim rst As DAO.Recordset
Dim lngCount As Long

Set rst = CurrentDb.OpenRecordset("YourQuery")

With rst
.MoveFirst
.MoveLast
lngCount = .RecordCount
End With

Debug.Print "Number of Records = " & lngCount

End Function

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


"David Widener" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Is there an easy way to count the records in a table without opening the
> table and counting each record some sort of a listfile function the gives
> you
> a count ???, any help would be appreciated.
>
>



 
Reply With Quote
 
 
 
 
Andi Mayer
Guest
Posts: n/a
 
      26th Jan 2005
On Wed, 26 Jan 2005 06:39:02 -0800, "David Widener"
<(E-Mail Removed)> wrote:

>Is there an easy way to count the records in a table without opening the
>table and counting each record some sort of a listfile function the gives you
>a count ???, any help would be appreciated.
>


currentdb.TableDefs("myTablename").RecordCount

---
If you expect an answer to a personal mail, add the word "manfred" to the first 10 lines in the message
MW
 
Reply With Quote
 
Rick Brandt
Guest
Posts: n/a
 
      26th Jan 2005
Andi Mayer wrote:
> On Wed, 26 Jan 2005 06:39:02 -0800, "David Widener"
> <(E-Mail Removed)> wrote:
>
>> Is there an easy way to count the records in a table without opening
>> the table and counting each record some sort of a listfile function
>> the gives you a count ???, any help would be appreciated.
>>

>
> currentdb.TableDefs("myTablename").RecordCount


The above only works against a local Jet table. A linked table of any kind
will just return -1.


--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


 
Reply With Quote
 
=?Utf-8?B?RGF2aWQgV2lkZW5lcg==?=
Guest
Posts: n/a
 
      26th Jan 2005
Thanks Andi that's exactly what I needed

"Andi Mayer" wrote:

> On Wed, 26 Jan 2005 06:39:02 -0800, "David Widener"
> <(E-Mail Removed)> wrote:
>
> >Is there an easy way to count the records in a table without opening the
> >table and counting each record some sort of a listfile function the gives you
> >a count ???, any help would be appreciated.
> >

>
> currentdb.TableDefs("myTablename").RecordCount
>
> ---
> If you expect an answer to a personal mail, add the word "manfred" to the first 10 lines in the message
> MW
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change existing table record value by VBA and How to add newrecord in existing table by VBA K Microsoft Access Form Coding 1 18th May 2010 09:54 AM
How to change existing table record value by VBA and How to add newrecord in existing table by VBA K Microsoft Access Database Table Design 1 18th May 2010 09:20 AM
Count New to the List, Count Leaving the List, Count Total SteveC Microsoft Excel Misc 1 2nd Feb 2009 10:48 PM
how to get count(col1), count(col2), count(sol3) with only one query Mario Krsnic Microsoft Access Queries 2 27th Oct 2006 06:52 PM
Current Record Count, Previous Record #, Add New Record =?Utf-8?B?Um9iZXJ0IE51c3ogQCBEUFM=?= Microsoft Access Forms 0 15th Feb 2005 09:35 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:38 PM.