Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 16th, 2008, 04:43 AM
Friend of Wrox
 
Join Date: Apr 2007
Location: , , .
Posts: 110
Thanks: 1
Thanked 2 Times in 2 Posts
Send a message via MSN to ayazhoda
Default How to do record count for Link table in access

Hi All

I've wrote a module, which does record count for each table in database

Question: How can only count records from linked table?
currently it does count records for each table in database.


Option Compare Database

Sub Recordsintables()

Dim x As Integer
Dim count As Integer
Dim Name As String


Dim i As Integer
Dim tables As String
Dim r As New ADODB.Recordset

'Debug.Print "Total Table In Database include system Table: " & CurrentDb.TableDefs.count

For i = 0 To CurrentDb.TableDefs.count - 1

    DoEvents

    tables = CurrentDb.TableDefs(i).Name
   If Left(tables, 4) <> "dbo_" And Left(tables, 4) <> "bak_" And Left(tables, 4) <> "MSys" Then

            Debug.Print "Table Name: " & tables & " - Count: " & recordcount(tables)

        End If
Next i

End Sub

Function recordcount(tbl As String) As Long
Dim c As New ADODB.Command
c.ActiveConnection = CurrentProject.Connection
c.CommandText = "select count(*) from [" + tbl + "]"
Dim r As ADODB.Recordset
Set r = c.Execute
r.MoveFirst
recordcount = r.Fields(0).Value
r.Close
End Function


Reply With Quote
Reply


Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Record count deb1980 ASP.NET 2.0 Basics 6 April 10th, 2007 12:42 PM
can to link a ms access table to sql server? sugar SQL Server 2000 6 May 23rd, 2006 11:45 AM
Link Table In Access 2000 VB GURU Access VBA 6 March 16th, 2006 05:22 PM
RDS Single Record and Table Binding with Access qwerty Classic ASP Databases 0 July 15th, 2003 02:20 PM



All times are GMT -4. The time now is 05:42 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.