Delete DB objects

P

Pietro

Hi,

Is there a code to delete all database queries and forms.
Currently I'm using the below codes, but actually the one the deletes the
forms cannot delete the one that currently open,so all the forms are deleted
except one, how can i delete everything?

Code to delete forms:
On Error Resume Next
If Date >= #12/31/2008# Then
DoCmd.Close acForm, "login"
DoCmd.Close acForm, "passme"
Dim db As Database
Dim objform As Object
Set db = CurrentDb
For Each objform In db.Containers("Forms").Documents
DoCmd.DeleteObject acForm, objform.Name
Next
End If

Code to delete queries:
On Error Resume Next
If Date >= #12/31/2008# Then
DoCmd.Close acForm, "login"
DoCmd.Close acForm, "passme"
Dim db As DAO.Database, i
Set db = CurrentDb
For i = 0 To db.QueryDefs.Count - 1
DoCmd.DeleteObject acQuery, db.QueryDefs(i).Name
Next i
End If
 
U

unknown

Create a new macro and under Action you select RunBasicCode.

Under "Fuction" enter the name of the function you wish to execute,
=MyFunction()

Jan R

Pietro skrev:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Delete open forms 6
Why can't it find my objects? 3
Message body 9
Iterate through tables 2
Get User 1
access 2007 - vba - forms collection 4
Table Linking Code Problem 10
Syntax error in FROM clause 1

Top