Removing Queries with Code

MikeAngelastro

Registered User.
Local time
Today, 06:39
Joined
Mar 3, 2000
Messages
254
Hi,

Does anyone know the VBA code to remove all queries, forms, reports, etc from a given Access database? Removong them manually takes too long.

Thanks,

Mike
 
Using DAO or ADO? If you're not sure, which version of Access are you using?
 
Code:
Public Function DeleteAllTables()
  Dim tbl As Obejct

  For Each tbl in currentdata.alltables
    Docmd.deleteobject tbl.name
  next tbl
End Function
tables/queries are in currentdata, forms/reports are in currentproject
 
I thought we were looking for DAO code. :confused:
 
No, we were looking for the question 'how to remove access-objects via code' ;)

It's also possible with DAO and ADO, but why should you make it yourself difficult if it's so easy :)

greetz,
Bert
 
SforSoftware said:
What's the problem you've?
If you look at my question above, I asked the user if he/she needed ADO or DAO. The user replied with "DAO". That's the problem. :)
 
okay, that seems to be your problem, but not the of uncle gizmo :P
 
okay, you're right, my code isn't complete (because I wrote it in the forum-editor ;))
it must be:
Code:
Public Function fConList()
  Dim tbl As AccessObject
  
  For Each tbl In CurrentData.AllTables
    If Left(tbl.Name, 4) <> "msys" Then
      DoCmd.DeleteObject acTable, tbl.Name
    End If
  Next tbl
End Function
 

Users who are viewing this thread

Back
Top Bottom