Solved

Checking databases table

Posted on 2000-03-21
2
146 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Title # Comments Views Activity
VB 6.0 printer how to align 6 71
Paint/Redraw window while dragging 16 85
Best way to parse out a json string in VB6? 10 276
How to measure sizes and angles in scanned images ? 3 87
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

680 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