?
Solved

Check a Table exists before deleting it

Posted on 2014-10-24
2
Medium Priority
?
159 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 2000 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
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…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Suggested Courses

770 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