Solved

Checking databases table

Posted on 2000-03-21
2
137 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now