Solved

Check a Table exists before deleting it

Posted on 2014-10-24
2
156 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
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
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…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

838 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