474,048 Members | 1,793 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I get all table names from MS Access

I'm using VB and I need to get all table names in database. How can I do
that?

Thank you.
Nov 12 '05 #1
4 5840
Mlaky wrote:
I'm using VB and I need to get all table names in database. How can I do
that?

Thank you.

select name from msysobjects where type=1

--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Nov 12 '05 #2
Public Function GetTableNamesDA O(ByVal strDatabase As String) As String()

'requires reference to DAO object library

Dim straTableNames( ) As String
Dim db As DAO.Database
Dim lngLoop As Long

Set db = DBEngine.OpenDa tabase(strDatab ase)
ReDim straTableNames( db.TableDefs.Co unt - 1)
For lngLoop = 0 To db.TableDefs.Co unt - 1
straTableNames( lngLoop) = db.TableDefs(ln gLoop).Name
Next lngLoop
db.Close
GetTableNamesDA O = straTableNames

End Function

Public Sub TestGetTableNam esDAO()

'used for testing within Access - will need modification for VB

Dim straTableNames( ) As String
Dim lngLoop As Long

straTableNames = GetTableNamesDA O(CurrentProjec t.FullName)
For lngLoop = LBound(straTabl eNames) To UBound(straTabl eNames)
Debug.Print straTableNames( lngLoop)
Next lngLoop

End Sub

Public Function GetTableNamesAD OX(ByVal TheConnection As ADODB.Connectio n)
As String()

'requires references to ADODB and ADOX object libraries

Dim straTableNames( ) As String
Dim cat As ADOX.Catalog
Dim lngLoop As Long
Dim boolOpenedConne ction As Boolean

If TheConnection.S tate <> adStateOpen Then
TheConnection.O pen
boolOpenedConne ction = True
End If
Set cat = New ADOX.Catalog
cat.ActiveConne ction = TheConnection
ReDim straTableNames( cat.Tables.Coun t - 1)
For lngLoop = 0 To cat.Tables.Coun t - 1
straTableNames( lngLoop) = cat.Tables(lngL oop).Name
Next lngLoop
GetTableNamesAD OX = straTableNames
If boolOpenedConne ction Then
TheConnection.C lose
End If

End Function

Public Function TestGetTableNam esADOX()

'used for testing within Access - will need modification for VB

Dim straTableNames( ) As String
Dim lngLoop As Long

straTableNames = GetTableNamesAD OX(CurrentProje ct.Connection)
For lngLoop = LBound(straTabl eNames) To UBound(straTabl eNames)
Debug.Print straTableNames( lngLoop)
Next lngLoop

End Function

--
Brendan Reynolds
"Mlaky" <ml************ @email.htnet.hr > wrote in message
news:c0******** **@ls219.htnet. hr...
I'm using VB and I need to get all table names in database. How can I do
that?

Thank you.

Nov 12 '05 #3
I can't do that. I've got following message:

Error: Record(s) cannot be read; no read permission on 'msysobjects'.
select name from msysobjects where type=1

--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Nov 12 '05 #4
"Mlaky" <ml************ @email.htnet.hr > wrote in news:c0sto0$knj $1
@ls219.htnet.hr :
I can't do that. I've got following message:
Error: Record(s) cannot be read; no read permission on 'msysobjects'.
select name from msysobjects where type=1
--
Bas Cost Budde


For Version >= 2K:

Public Function GetTableNames() As ADODB.Recordset
Set GetTableNames = CurrentProject. Connection.Open Schema
(adSchemaTables , Array(Empty, Empty, Empty, "Table"))
End Function

Sub test()
Debug.Print GetTableNames.G etString(, , ",", , vbTab)
End Sub
--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #5

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

Similar topics

36
4728
by: toedipper | last post by:
Hello, I am designing a table of vehicle types, nothing special, just a list of unique vehicle types such as truck, lorry, bike, motor bike, plane, tractor etc etc For the table design I am proposing a single column table with a field name called vehicle_type and this will contain the vehicle type. Sot it will be
3
18542
by: Tom | last post by:
Data is collected over time in an Excel worksheet with 20 columns. The Excel worksheet starts out as a copy of a template as is filled in as data is collected. Eventually the worksheet file is saved and an Access table is linked to the Excel worksheet. Different people collect the data in the Excel worksheet than who use the database. The fields in the table are the labels in the first row of the worksheet which is what I want. The...
6
2299
by: Bernd Koehler | last post by:
Hi: I am a EE prof currently teaching an IT course. One the assignments students recently completed was designing a small MS Access Database. I have two submissions that are remarkably similiar..<sigh> the structure (number of tables, field names, table names) is virtually identical. Some of the data in each table is different.
5
4365
by: premmehrotra | last post by:
I am using Microsoft Access 2000 and Oracle 9.2.0.5 on Windows 2000. When I export a table from Access to Oracle using ODBC I get error: ORA 972 identifier too long I think the error is because one or more columns in Access table are longer than 30 characters. My question is how one can overcome this problem. I also see several column names which have /, ? or spaces in name
6
6319
by: davegb | last post by:
I'm trying to create a self-join table to show the relationship between employee and supervisor. In another thread, I was advised to create a SupervisorID in the employee table, a separate Supervisor table, and join the Supervisor table to the Employee table and a copy of the Supervisor table to create the self-join. I can't figure out how to do this from reading Viescas or from researching it here. I can start a query and create 2 copies...
6
4881
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID SalesManName AT Alan Time
3
1988
by: David C. Barber | last post by:
Using SQL Server 2000 and moving to a new computer. We did a full backup of the existing database to tape, brought up the new computer with a clean install using the same server name and IP address, and did a full restore. Not only were some permissions messed up, but Crystal Reports 10 and some Access Data Projects refused to run. I finally discovered while running an SP_WHO that the individual database names that we'd created (meaning...
11
10339
by: Tim Hunter | last post by:
Hi I am using WinXP and Access 2003 Is it possible to store the field names of a table in an array and then loop through the array and update the table using the field names stored in the array? I can't figure out the coding to accomplish this. I have an Excel application that is a monster and it has become too much to maintain and test. I didn't write it but i support it. I am trying to convert this application to Access and it is not as...
4
22627
by: Bob | last post by:
Hi all, I've got a table that I've imported and it has junk at the top of the table, so after import I run a delete query to remove the junk lines then I'm left with the field names I want for the table at the top of the table but the field names currently are 'field1' etc, so how do I rename the field names to the fields on the top row of the table. Cheers,
2
3373
by: myemail.an | last post by:
Hi all, I need to export a table from Ms Sql to Access. However, dts import/ export gives me an error because the field names are too long. Is there a quick way to trim the names of all fields to the 64 characters allowed by Access? Or is there a better alternative? Thanks!
0
10554
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
10357
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
12157
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...
0
11616
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
12046
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,...
1
8711
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
6667
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4951
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3983
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.