Solved

Check a Table exists before deleting it

Posted on 2014-10-24
2
152 Views
Last Modified: 2014-10-24
Dear Experts,

Courtesy of EE Access, I have a piece of code which should check to see if an access table exists, if it does then it deletes it.

Unfortunately I keep getting an error - User defined type not defined (it highlights the line ... Dim td As DAO.TableDef)

The code is below, can anybody help?

Private Function UpdateTables_Click()
DoCmd.OpenForm "Refreshing"
DoCmd.SetWarnings False
'Test for tables
Dim td As DAO.TableDef
On Error Resume Next
Set td = CurrentDb.TableDefs("Dbo_AppointmentsView")
If Err = 0 Then DoCmd.DeleteObject acTable, "Dbo_AppointmentsView"
Else
Err.Clear
End If
Set td = CurrentDb.TableDefs("dbo_AssignmentFeeAllocationsView")
If Err = 0 Then DoCmd.DeleteObject acTable, "dbo_AssignmentFeeAllocationsView"
Else
Err.Clear
End If

'next table etc etc 

Open in new window

0
Comment
Question by:correlate
2 Comments
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
Comment Utility
In the VBA editor window, go to tools, references.

Scroll down the list and find "Microsoft DAO 3.60 Object Library"  and check it.

Click OK and you will be set.

Jim.
0
 

Author Closing Comment

by:correlate
Comment Utility
Perfect thank you very much
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

763 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

6 Experts available now in Live!

Get 1:1 Help Now