Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Checking databases table

Posted on 2000-03-21
2
145 Views
Last Modified: 2010-05-02
I wanna check if my database (Access)contains certain table. Below is an example how I tryed to do it but it didn't work.

MyData.DatabaseName = MyFile
 
For i = 0 To MyData.Database.TableDefs.Count - 1

 If MyData.Database.TableDefs(i).Name = "MyTable" Then
   ThereIsOne = True
 End If

Next

Could you give an example.

Thanks in advance!
0
Comment
Question by:majala
  • 2
2 Comments
 

Accepted Solution

by:
pinshah earned 50 total points
ID: 2643435
Public Function IsTableExist(TableName As String) As Boolean
Dim o As Database
Dim stext As String

On Error Goto DBErrorHandler

Set o = OpenDatabase(DatabaseFile)
o.TableDefs.Count
stext =   o.TableDefs(TableName).Name

IsTableExist = True


Exit Function

DBErrorHandler:
'Handle the errnumber which DAO throws
'if the table entry is not found i think its 3265

if Err.Number = 3265 Then
IsTableExist = False
End if

End Function
0
 

Expert Comment

by:pinshah
ID: 2643438
One change remove the o.tabledefs.count
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question