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

Count records of all linked tables in 2007 database

Do not understand this one:
SELECT
Table_Name = Name,
Row_Count = DCount("*",[MSysObjects].[Name])
FROM
MSysObjects
WHERE
(Left([Name],1)<>"~")
AND (Left([Name],4) <> "MSys")
AND ([Type] In (1, 4, 6))
ORDER BY
Name
My tables are: FES02AVTALL, FES02GRDALL, and each after etc.

this one works but returns the total number on rows that never stop:
SELECT
(Select Count(Process) From FES02AVTALL) As FY02AVT,
(Select Count(Process) From FES02GRDALL) As FY02GRD,
(Select Count(Process) From FES03AVTALL) As FY03AVT,
(Select Count(Process) From FES03GRDALL) As FY03GRD
From FES02AVTALL, FES02GRDALL, FES03AVTALL, FES03GRDALL;


all help is appriciated.

Sam
Jul 30 '09 #1
7 7542
ADezii
8,834 Expert 8TB
@samvaldez
Hello Sam, I wrote some very simple code for you that will list each Linked Table's Name along with the Number of Records contained within.
Expand|Select|Wrap|Line Numbers
  1. Dim tdf As DAO.TableDef
  2.  
  3. For Each tdf In CurrentDb.TableDefs
  4.   If Len(tdf.Connect) > 0 Then    'it is a Linked Table
  5.     Debug.Print tdf.Name & " has " & DCount("*", tdf.Name) & " Records!"
  6.   End If
  7. Next
Aug 1 '09 #2
Okay, created a command button reads like:
Private Sub Command72_Click()

Dim tdf As DAO.TableDef

For Each tdf In CurrentDb.TableDefs
If Len(tdf.Connect) > 0 Then 'it is a Linked Table (this is green out)
Debug.Print tdf.Name & " has " & DCount("*", tdf.Name) & " Records!"
End If
Next
End Sub

I did not recive anything, have I done something wrong?
Aug 3 '09 #3
ADezii
8,834 Expert 8TB
@samvaldez
I did not receive anything, have I done something wrong?
No, it simply means that you have no Linked Tables. To verify this, expand the previous code to:
Expand|Select|Wrap|Line Numbers
  1. Dim tdf As DAO.TableDef
  2.  
  3. For Each tdf In CurrentDb.TableDefs
  4.   If Len(tdf.Connect) > 0 Then    'it is a Linked Table (this is green out)
  5.     Debug.Print tdf.Name & "[Linked] has " & DCount("*", tdf.Name) & " Records!"
  6.   Else
  7.     Debug.Print tdf.Name & "[Non-Linked] has " & DCount("*", tdf.Name) & " Records!"
  8.   End If
  9. Next
P.S. - I intentionally did not filter out the System Tables to keep things simple,
Aug 3 '09 #4
I am working with 2007 Access.
the db i'm working in is the front end that users access. all tables are linked.

I'm i doing this correct with a command button?
Is their anything else I should do prior to copy and paste into the event of the button?

this is how command72 event reads:

Private Sub Command72_Click()

Dim tdf As DAO.TableDef

For Each tdf In CurrentDb.TableDefs
If Len(tdf.Connect) > 0 Then 'it is a Linked Table
Debug.Print tdf.Name & "[Linked] has " & DCount("*", tdf.Name) & " Records!"
Else
Debug.Print tdf.Name & "[Non-Linked] has " & DCount("*", tdf.Name) & " Records!"
End If
Next

End Sub
-------------------------

will the data open in a table?

Thanks
Aug 3 '09 #5
ADezii
8,834 Expert 8TB
@samvaldez
I just realized that I may have made an assumption that I should not have, and that is that you know how to access the DEBUG/Immediate Window. After executing this code, press the CTRL + G Key Combination to Open the DEBUG/Immediate Window. Another Option is to replace the Debug.Print Statement with Msgbox.
Aug 3 '09 #6
Great!
Changed to Msgbox. However, it is only returning non-linked tables.

is their also a way to have all listed in one box or querry/table?

thanks for your help.

Sam
Aug 3 '09 #7
ADezii
8,834 Expert 8TB
@samvaldez
Copy and Paste the following SQL Statement into the SQL View of the Query Design Window and everything that you request will be in the Form of a Query.
Expand|Select|Wrap|Line Numbers
  1. SELECT MSysObjects.Name,IIF([Type]=4,'Linked','Non-Linked') As Status,  
  2. DCount("*",[MSysObjects].[Name]) AS[Record Count]
  3. FROM MSysObjects
  4. WHERE (((Left([Name],1))<>"~") AND ((Left([Name],4))<>"MSys") AND 
  5. ((MSysObjects.Type) In (1,4,6)))
  6. ORDER BY MSysObjects.Name;
Sample OUTPUT for my PC:
Expand|Select|Wrap|Line Numbers
  1. Name          Status                    Record Count
  2. Bkup_Ctrl    Non-Linked                 1
  3. Categories    Non-Linked                 8
  4. Customers    Non-Linked               93
  5. dbo_authors    Linked               23
  6. dbo_titles    Linked                               18
  7. Employee_ImportErrors    Non-Linked    225
  8. Employees    Non-Linked    9
  9. Employees2    Non-Linked    1
  10. Horatio    Non-Linked    10
  11. Order Details    Non-Linked    2158
  12. Orders    Non-Linked    856
  13. Products    Non-Linked    77
  14. ServiceRec    Non-Linked    10
  15. Shippers    Non-Linked    3
  16. Suppliers    Non-Linked    29
  17. Table1    Non-Linked    6
  18. TBL_DATA    Non-Linked    4
  19. tbl_EXTRACT_070709    Non-Linked    1
  20. tblAccount    Non-Linked    9
  21. tblCrop    Non-Linked    5
  22. tblDOS    Non-Linked    4
  23. tblEMailAddress    Non-Linked    4
  24. tblEmployee    Non-Linked    225
  25. tblKeywords    Non-Linked    4
  26. tblOrders    Non-Linked    9
  27. tblPrefixes    Non-Linked    3
  28. tblReports    Non-Linked    2
  29. tblSales    Non-Linked    3
  30. tblSuffixes    Non-Linked    4
  31. tblTest    Non-Linked    6
  32. tShipDetails    Non-Linked    16
P.S. - Sorry, simply do not have the time to properly Format the results.
Aug 3 '09 #8

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

Similar topics

1
by: Henry Stockbridge | last post by:
Hi, I am doing database documentation and run the procedure below to list the record count for each table in the database. The results in the immediate window only a partial listing of tables. ...
1
by: jnikle2100 | last post by:
I have a simple database comprised of two tables. tbl_employee_info stores employee info (name, hire date, title, etc.) and tbl_departmental_history stores departmental transfer history. The two...
15
by: brettclare | last post by:
I have linked a large SQL Server table to Access, however 'only' 2,195,439 records are shown and are available to query. Can I increase the size (cache??)/number of records showing in Access? ...
3
by: Rashapoo | last post by:
I have just completed a basic course in Access. I have some relational b/g in DB2 and Cobol. I have a question my instructor couldn't answer (or maybe I didn't explain myself) I design a...
4
by: Peter W Johnson | last post by:
Hi guys, I have a problem with a datagrid record count. Here is the code:- <snip> Public Class frmMerchantDeposit Inherits System.Windows.Forms.Form Dim myconnection As New...
6
by: gerbski | last post by:
Hi all, I am relatively new to ADO, but up to now I got things working the way I wanted. But now I've run into somethng really annoying. I am working in MS Access. I am using an Access...
5
by: Neil | last post by:
I'm running Access 2000 with a SQL 7 back end, using ODBC linked tables in an MDB file. The db is used by about 30 users on a LAN, and an additional 10 or so on a WAN. Recently, one of the WAN...
3
by: ARC | last post by:
I'm having trouble here with Access 2007 and connecting to a different database. The code below works great IF the previous back-end database connection is still present and you are trying to...
4
by: thayes5150 | last post by:
I have an Access 2003 database linked to an MS SQL 2005 backend. We use the database as part of a process whereby we use Zone OCR to scan records off paper forms into an XML file, suck the data off...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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
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...

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.