Solved

Check a Table exists before deleting it

Posted on 2014-10-24
2
158 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
[X]
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
2 Comments
 
LVL 58

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 40401817
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
ID: 40401843
Perfect thank you very much
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

726 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