From: MVP - WannaB on
I have a form that will not open in normal or design mode and there are 2
Form_~TMPCLP######## objects in my VBA Project window, and there are 2
Objects with the same name in the MsysObjects table of type 32678 which means
they are forms. I expect that if I am able to delete these I might be able
to salvage my form.

However, Nothing I have tried allows me to delete anything from MsysObjects.
OH there is one other issue, Not able to run any code from the data base
with that form in it. I get a message that the module can't be found...
Nothign specific. So I have been working on something that I would run from
a different database file, like this. Can someone correct my mistake or tel
me where I've gone wrong ?
Thank you.

Function DeleteTemps()
Dim db As DAO.Database
Dim Rs As DAO.Recordset
Set db = OpenDatabase("PATH\FILENAME")

Set Rs = db.OpenRecordset("SELECT * FROM MSysObjects WHERE
(((MSysObjects.Name) Like ""~*"") AND ((MSysObjects.Type = -32768)))") ';,
DAO.dbOpenSnapshot)
Rs.MoveLast
Rs.MoveFirst
While Not Rs.EOF
Access.DoCmd.DeleteObject Access.AcObjectType.acForm, Rs.Fields(0).Value
Rs.MoveNext
Wend
Rs.Close
Set Rs = Nothing
Set db = Nothing
End Function

From: Jerry Whittle on
Open a new database file. Import everything from your problem database into
it. If something, such as the problem form, won't move over, it's toast. In
that case import the form from a recent backup.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"MVP - WannaB" wrote:

> I have a form that will not open in normal or design mode and there are 2
> Form_~TMPCLP######## objects in my VBA Project window, and there are 2
> Objects with the same name in the MsysObjects table of type 32678 which means
> they are forms. I expect that if I am able to delete these I might be able
> to salvage my form.
>
> However, Nothing I have tried allows me to delete anything from MsysObjects.
> OH there is one other issue, Not able to run any code from the data base
> with that form in it. I get a message that the module can't be found...
> Nothign specific. So I have been working on something that I would run from
> a different database file, like this. Can someone correct my mistake or tel
> me where I've gone wrong ?
> Thank you.
>
> Function DeleteTemps()
> Dim db As DAO.Database
> Dim Rs As DAO.Recordset
> Set db = OpenDatabase("PATH\FILENAME")
>
> Set Rs = db.OpenRecordset("SELECT * FROM MSysObjects WHERE
> (((MSysObjects.Name) Like ""~*"") AND ((MSysObjects.Type = -32768)))") ';,
> DAO.dbOpenSnapshot)
> Rs.MoveLast
> Rs.MoveFirst
> While Not Rs.EOF
> Access.DoCmd.DeleteObject Access.AcObjectType.acForm, Rs.Fields(0).Value
> Rs.MoveNext
> Wend
> Rs.Close
> Set Rs = Nothing
> Set db = Nothing
> End Function
>
 | 
Pages: 1
Prev: Autonumbering Query
Next: if statement help