473,769 Members | 4,089 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I have declared an array Dim MyTables(14) AS Long and now I want to assign values for MyTables(0 - 15) = to the number of records in each table

MLH
Gentlemen: I have declared an array

Dim MyTables(14) AS Long

Now I want to assign values for MyTables(0) - MyTables(14) equal
to the number of records in each table. Catch, I want the code to
identify only those tables beginning with the letters "JA". Is this
possible? Or, should I break down and manually type in all the
table names?
Nov 13 '05 #1
2 1842

"MLH" <CR**@NorthStat e.net> wrote in message
news:p0******** *************** *********@4ax.c om...
Gentlemen: I have declared an array

Dim MyTables(14) AS Long

Now I want to assign values for MyTables(0) - MyTables(14) equal
to the number of records in each table. Catch, I want the code to
identify only those tables beginning with the letters "JA". Is this
possible? Or, should I break down and manually type in all the
table names?


Dim dbs As Database
Dim tdf As TableDef
Dim tdfLength As Integer
Set dbs = CurrentDb
With dbs
For Each tdf In .TableDefs
If Left(tdf.Name, 2) = "JA" Then
'Do your stuff here
End If
Next tdf
End With
Nov 13 '05 #2
"MLH" wrote
I have declared an array

Dim MyTables(14) AS Long

Now I want to assign values for
MyTables(0) - MyTables(14) equal
to the number of records in each table.
Catch, I want the code to identify only
those tables beginning with the letters "JA".


How do you expect to relate the Tables to the values for number of Records?
You can "run the Tables collection" to obtain the Table Names, execute a
DCount function (or Open each Table with DAO code, MoveLast, and get the
Count), and save the count. Your code can select only those Tables whose
name begins with "JA" using If Left$(strTabNam ,2) = "JA" Then... but if you
have some need to identify the specific table with the count, you'll need
another array or an array that includes a string value and a numeric value.

You'll use something like the following code that saves and shows the tables
and record counts of all tables whose name begins with "tbl" in a test
database. (Since I usually beging counting with 1, I did so here, but you
can easily change that if you want to use the zero-based arrays as
zero-based.)

This is all the code from a module:

Option Compare Database
Option Explicit
Public strTabNam(0 To 30) As String
Public lngTabRec(0 To 30) As Long
Public intNoMembers As Integer

Function ClearArrays() As Boolean
Dim i As Integer
ClearArrays = False 'Preset for failure
For i = 0 To UBound(strTabNa m)
strTabNam(i) = ""
lngTabRec(i) = 0
Next i
intNoMembers = 0
ClearArrays = True 'Reset for success
End Function

Function FillArrays() As Integer
Dim db As DAO.Database
Dim td As DAO.TableDef
Set db = CurrentDb()
Debug.Print "Total Tables = "; db.TableDefs.Co unt - 1
For Each td In db.TableDefs
If Left(td.Name, 3) = "tbl" Then
intNoMembers = intNoMembers + 1
strTabNam(intNo Members) = td.Name
lngTabRec(intNo Members) = DCount("*", td.Name)
Debug.Print intNoMembers, strTabNam(intNo Members),
lngTabRec(intNo Members)
End If
Set td = Nothing
Next
FillArrays = intNoMembers
Set db = Nothing
End Function

Function ShowArrays() As Integer
Dim i As Integer
Dim j As Integer
Debug.Print "No. Tables in Arrays: "; intNoMembers
For i = 1 To intNoMembers
Debug.Print i, strTabNam(i), lngTabRec(i)
j = j + 1
Next i
ShowArrays = j
End Function

Here is the output from the Immediate Window (Access 2002).

? ClearArrays()
True
? FillArrays()
Total Tables = 23
1 tblAutoNumberTe st 10
2 tblCaseAndOutco meJunction 6
3 tblCaseOutcomes 3
4 tblCases 3
5 tblDriver 720
6 tblMadeANew 7
7 tblMadeANew1 7
8 tblOrderDetailM emo 1
9 tblSomeNullsSom eNot 3
10 tblTestAddingFi eld 10
10
? ShowArrays()
No. Tables in Arrays: 10
1 tblAutoNumberTe st 10
2 tblCaseAndOutco meJunction 6
3 tblCaseOutcomes 3
4 tblCases 3
5 tblDriver 720
6 tblMadeANew 7
7 tblMadeANew1 7
8 tblOrderDetailM emo 1
9 tblSomeNullsSom eNot 3
10 tblTestAddingFi eld 10
10
Larry Linson
Microsoft Access MVP


Nov 13 '05 #3

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

Similar topics

6
8397
by: John R | last post by:
Hi all, I'm trying to get my VB6 app to look up prefixes for a phone number out of an MDB file along with an associated price etc. For example the phone number could be 9802xxxx, and the MDB file will have the record 9802 with an associated price. I am used to connecting to databases via ADO, but my problem is that the MDB file may contain prefixes from 1 to 5 chars in length and i'm not sure how
1
1844
by: donhyams | last post by:
It seems like at one time I knew how to do this, but right now I'm drawing a blank. I know there has to be an easier way to link tables using more than one field. Heres a simplfication of the problem: I have two tables that are not normally linked to each other: ------------ tblClientStatusDetails with these fields: ...ClientStatusID = Autonumber (Primary Key)
13
2699
by: Shannan Casteel via AccessMonster.com | last post by:
I set up two tables (one with the regular claim info and another with ClaimNumber, PartNumber, and QuantityReplaced). The ClaimNumber is an autonumber and the primary key in both tables. I made a one to one relationship between the two tables. I have a form for the parts. It includes 25 text boxes for both the part numbers and the quantities, so 50 total. I set the control sources for each of the part number text boxes to PartNumber...
1
2847
by: tHeRoBeRtMiTcHeLL | last post by:
Below is an earlier post to an Excel Group.. ....but I thought that there might be a way to do this in Access by importing data and then creating append and/or update query. I would most certainly need to use the right type of table join and criteria in the query to perform the task, and don't find myself an expert or up to par as far as I'm concerned. *******************************************************************
5
12721
by: XML newbie: Urgent pls help! | last post by:
function to convert string to 1 dimensional array of long in VB.Net
4
2388
by: General Fear | last post by:
I would like assign a number to each row in the table. The number can be row number. For example, the first record in the table can be number 1. I can do this thru VBA code. Can I do this via SQL ? If so, how? ...
2
3262
by: kevinjbowman | last post by:
I am by no means a SQl Jedi as will be apparent by my question, but I can usually figure out a select statement on my own. I have one today though that really has me stumped. I am working in MySQlL 5. In My first select statement I get all my records from Table B SELECT `table_A`.`ITEM`, `table_A`.`DECSCRIPTION`, `table_A`.`UM`, `table_A`.`PHASE`,
2
5565
by: dlevene | last post by:
Hi - newbie here, be gentle. In Access 2003, I've created a report (based on a query) to produce mailing labels for all records where = "Community". is a combo-box field with the values coming from a seperate table. Problem is, some of these don't have addresses (ie. , and are null). So I want to use the address of the Administrator for that community. This information is in records where = "Administrator" and = whatever the community...
0
9579
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9422
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10208
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9987
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9857
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7404
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2812
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.