What does this mean? 
Author Message
 What does this mean?

I receive this error:

29068 - Form1 cannot complete this operation. You must stop the code and try
again.

Here is the code where the error occurs:
***BEGIN CODE***
Set dbs = CurrentDb()
    With dbs.Containers!Forms
        For Each doc In .Documents
            If doc.NAME Like "*" & lastModule & "_*" Then
                Debug.Print doc.NAME & " deleted."
                DoCmd.DeleteObject acForm, doc.NAME <---Error Occurs
            End If
        Next doc
    End With
***END CODE***

How can I stop this error from happening?
I am trapping it right now.
WinXP Pro and AccessXP
--
TIA.
Good Luck.
Jeff R.



Sun, 22 May 2005 05:15:15 GMT  
 What does this mean?
For some reason you need to do something like the following

Dim doc As Document
Dim dbs As Database
Dim strLastName As String
Dim ctr As Container
Set dbs = CurrentDb()
Set ctr = dbs.Containers("Forms")

         For Each doc In ctr.Documents
                ' Debug.Print doc.Name

            If strLastName = "frmbtest" Then
                DoCmd.DeleteObject acForm, strLastName
            End If
            strLastName = doc.Name
         Next doc

you will need to add something here to wrap up for the last form in the
database

Might want to put a call in the loop so you can call it again in the wrapup.
I noticed that it actually deleted the form then generated the error. must
be something to do with having it in the loop while you are deleting it.
hope this helps.


Quote:
> I receive this error:

> 29068 - Form1 cannot complete this operation. You must stop the code and
try
> again.

> Here is the code where the error occurs:
> ***BEGIN CODE***
> Set dbs = CurrentDb()
>     With dbs.Containers!Forms
>         For Each doc In .Documents
>             If doc.NAME Like "*" & lastModule & "_*" Then
>                 Debug.Print doc.NAME & " deleted."
>                 DoCmd.DeleteObject acForm, doc.NAME <---Error Occurs
>             End If
>         Next doc
>     End With
> ***END CODE***

> How can I stop this error from happening?
> I am trapping it right now.
> WinXP Pro and AccessXP
> --
> TIA.
> Good Luck.
> Jeff R.




Sun, 22 May 2005 05:48:51 GMT  
 What does this mean?
I should add that the frmbtest was the name i used to test the code. you
will need to put you lastModule code in there.


Quote:
> For some reason you need to do something like the following

> Dim doc As Document
> Dim dbs As Database
> Dim strLastName As String
> Dim ctr As Container
> Set dbs = CurrentDb()
> Set ctr = dbs.Containers("Forms")

>          For Each doc In ctr.Documents
>                 ' Debug.Print doc.Name

>             If strLastName = "frmbtest" Then
>                 DoCmd.DeleteObject acForm, strLastName
>             End If
>             strLastName = doc.Name
>          Next doc

> you will need to add something here to wrap up for the last form in the
> database

> Might want to put a call in the loop so you can call it again in the
wrapup.
> I noticed that it actually deleted the form then generated the error. must
> be something to do with having it in the loop while you are deleting it.
> hope this helps.



> > I receive this error:

> > 29068 - Form1 cannot complete this operation. You must stop the code and
> try
> > again.

> > Here is the code where the error occurs:
> > ***BEGIN CODE***
> > Set dbs = CurrentDb()
> >     With dbs.Containers!Forms
> >         For Each doc In .Documents
> >             If doc.NAME Like "*" & lastModule & "_*" Then
> >                 Debug.Print doc.NAME & " deleted."
> >                 DoCmd.DeleteObject acForm, doc.NAME <---Error Occurs
> >             End If
> >         Next doc
> >     End With
> > ***END CODE***

> > How can I stop this error from happening?
> > I am trapping it right now.
> > WinXP Pro and AccessXP
> > --
> > TIA.
> > Good Luck.
> > Jeff R.




Sun, 22 May 2005 05:50:23 GMT  
 What does this mean?
I'm just speculating, but I wonder if you can't delete the form while
you have a reference to it in the "doc" object variable.  You might
try setting doc = Nothing before deleting;  something like this:

Dim strDocName As String

Set dbs = CurrentDb()
    With dbs.Containers!Forms
        For Each doc In .Documents
            If doc.NAME Like "*" & lastModule & "_*" Then
                strDocName = doc.Name
                Set doc = Nothing
                Debug.Print strDocName & " deleted."
                DoCmd.DeleteObject acForm, strDocName
            End If
        Next doc
    End With

I'm curious to know if this fixes the problem.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


Quote:
> I receive this error:

> 29068 - Form1 cannot complete this operation. You must stop the code
and try
> again.

> Here is the code where the error occurs:
> ***BEGIN CODE***
> Set dbs = CurrentDb()
>     With dbs.Containers!Forms
>         For Each doc In .Documents
>             If doc.NAME Like "*" & lastModule & "_*" Then
>                 Debug.Print doc.NAME & " deleted."
>                 DoCmd.DeleteObject acForm, doc.NAME <---Error Occurs
>             End If
>         Next doc
>     End With
> ***END CODE***

> How can I stop this error from happening?
> I am trapping it right now.
> WinXP Pro and AccessXP
> --
> TIA.
> Good Luck.
> Jeff R.




Sun, 22 May 2005 06:05:18 GMT  
 What does this mean?
It still gave the same error, Dirk.

--
TIA.
Good Luck.
Jeff R.


Quote:
> I'm just speculating, but I wonder if you can't delete the form while
> you have a reference to it in the "doc" object variable.  You might
> try setting doc = Nothing before deleting;  something like this:

> Dim strDocName As String

> Set dbs = CurrentDb()
>     With dbs.Containers!Forms
>         For Each doc In .Documents
>             If doc.NAME Like "*" & lastModule & "_*" Then
>                 strDocName = doc.Name
>                 Set doc = Nothing
>                 Debug.Print strDocName & " deleted."
>                 DoCmd.DeleteObject acForm, strDocName
>             End If
>         Next doc
>     End With

> I'm curious to know if this fixes the problem.

> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com

> (please reply to the newsgroup)



> > I receive this error:

> > 29068 - Form1 cannot complete this operation. You must stop the code
> and try
> > again.

> > Here is the code where the error occurs:
> > ***BEGIN CODE***
> > Set dbs = CurrentDb()
> >     With dbs.Containers!Forms
> >         For Each doc In .Documents
> >             If doc.NAME Like "*" & lastModule & "_*" Then
> >                 Debug.Print doc.NAME & " deleted."
> >                 DoCmd.DeleteObject acForm, doc.NAME <---Error Occurs
> >             End If
> >         Next doc
> >     End With
> > ***END CODE***

> > How can I stop this error from happening?
> > I am trapping it right now.
> > WinXP Pro and AccessXP
> > --
> > TIA.
> > Good Luck.
> > Jeff R.




Sun, 22 May 2005 22:24:05 GMT  
 What does this mean?
Actually, it occurs to me now that you may be running into the old
"deleting items from a collection while iterating through the
collection using For Each ... Next" problem.  Try it like this:

'----- start of code ---
Dim dbs As DAO.Database
Dim lngX As Long

Set dbs = CurrentDb()
With dbs.Containers("Forms").Documents
    For lngX = .Count - 1 To 0 Step -1
        If .Item(lngX).Name Like "*" & lastModule & "_*" Then
            Debug.Print .Item(lngX).Name & " deleted."
            DoCmd.DeleteObject acForm, .Item(lngX).Name
        End If
    Next lngX
End With
'----- end of code ---

This just worked for me in a test.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


Quote:
> It still gave the same error, Dirk.

> --
> TIA.
> Good Luck.
> Jeff R.



> > I'm just speculating, but I wonder if you can't delete the form
while
> > you have a reference to it in the "doc" object variable.  You
might
> > try setting doc = Nothing before deleting;  something like this:

> > Dim strDocName As String

> > Set dbs = CurrentDb()
> >     With dbs.Containers!Forms
> >         For Each doc In .Documents
> >             If doc.NAME Like "*" & lastModule & "_*" Then
> >                 strDocName = doc.Name
> >                 Set doc = Nothing
> >                 Debug.Print strDocName & " deleted."
> >                 DoCmd.DeleteObject acForm, strDocName
> >             End If
> >         Next doc
> >     End With

> > I'm curious to know if this fixes the problem.

> > --
> > Dirk Goldgar, MS Access MVP
> > www.datagnostics.com

> > (please reply to the newsgroup)



> > > I receive this error:

> > > 29068 - Form1 cannot complete this operation. You must stop the
code
> > and try
> > > again.

> > > Here is the code where the error occurs:
> > > ***BEGIN CODE***
> > > Set dbs = CurrentDb()
> > >     With dbs.Containers!Forms
> > >         For Each doc In .Documents
> > >             If doc.NAME Like "*" & lastModule & "_*" Then
> > >                 Debug.Print doc.NAME & " deleted."
> > >                 DoCmd.DeleteObject acForm, doc.NAME <---Error
Occurs
> > >             End If
> > >         Next doc
> > >     End With
> > > ***END CODE***

> > > How can I stop this error from happening?
> > > I am trapping it right now.
> > > WinXP Pro and AccessXP
> > > --
> > > TIA.
> > > Good Luck.
> > > Jeff R.




Sun, 22 May 2005 23:23:24 GMT  
 What does this mean?
Thanks for the info Dirk. But now I have another problem and unable to test.
Posted in this same newsgroup (Title: Help!!!! Sudden Corruption?)

--
TKS.
Good Luck.
Jeff R.


Quote:
> Actually, it occurs to me now that you may be running into the old
> "deleting items from a collection while iterating through the
> collection using For Each ... Next" problem.  Try it like this:

> '----- start of code ---
> Dim dbs As DAO.Database
> Dim lngX As Long

> Set dbs = CurrentDb()
> With dbs.Containers("Forms").Documents
>     For lngX = .Count - 1 To 0 Step -1
>         If .Item(lngX).Name Like "*" & lastModule & "_*" Then
>             Debug.Print .Item(lngX).Name & " deleted."
>             DoCmd.DeleteObject acForm, .Item(lngX).Name
>         End If
>     Next lngX
> End With
> '----- end of code ---

> This just worked for me in a test.

> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com

> (please reply to the newsgroup)



> > It still gave the same error, Dirk.

> > --
> > TIA.
> > Good Luck.
> > Jeff R.



> > > I'm just speculating, but I wonder if you can't delete the form
> while
> > > you have a reference to it in the "doc" object variable.  You
> might
> > > try setting doc = Nothing before deleting;  something like this:

> > > Dim strDocName As String

> > > Set dbs = CurrentDb()
> > >     With dbs.Containers!Forms
> > >         For Each doc In .Documents
> > >             If doc.NAME Like "*" & lastModule & "_*" Then
> > >                 strDocName = doc.Name
> > >                 Set doc = Nothing
> > >                 Debug.Print strDocName & " deleted."
> > >                 DoCmd.DeleteObject acForm, strDocName
> > >             End If
> > >         Next doc
> > >     End With

> > > I'm curious to know if this fixes the problem.

> > > --
> > > Dirk Goldgar, MS Access MVP
> > > www.datagnostics.com

> > > (please reply to the newsgroup)



> > > > I receive this error:

> > > > 29068 - Form1 cannot complete this operation. You must stop the
> code
> > > and try
> > > > again.

> > > > Here is the code where the error occurs:
> > > > ***BEGIN CODE***
> > > > Set dbs = CurrentDb()
> > > >     With dbs.Containers!Forms
> > > >         For Each doc In .Documents
> > > >             If doc.NAME Like "*" & lastModule & "_*" Then
> > > >                 Debug.Print doc.NAME & " deleted."
> > > >                 DoCmd.DeleteObject acForm, doc.NAME <---Error
> Occurs
> > > >             End If
> > > >         Next doc
> > > >     End With
> > > > ***END CODE***

> > > > How can I stop this error from happening?
> > > > I am trapping it right now.
> > > > WinXP Pro and AccessXP
> > > > --
> > > > TIA.
> > > > Good Luck.
> > > > Jeff R.




Sun, 22 May 2005 23:47:02 GMT  
 What does this mean?
Well Dirk,
    I made the changes, corrected the DB corruption and I'm still receiving
the same error.
29068 - Form1 cannot complete this operation. You must stop the code and try
again.

--
HTH.
Good Luck.
Jeff R.


Quote:
> Thanks for the info Dirk. But now I have another problem and unable to
test.
> Posted in this same newsgroup (Title: Help!!!! Sudden Corruption?)

> --
> TKS.
> Good Luck.
> Jeff R.



> > Actually, it occurs to me now that you may be running into the old
> > "deleting items from a collection while iterating through the
> > collection using For Each ... Next" problem.  Try it like this:

> > '----- start of code ---
> > Dim dbs As DAO.Database
> > Dim lngX As Long

> > Set dbs = CurrentDb()
> > With dbs.Containers("Forms").Documents
> >     For lngX = .Count - 1 To 0 Step -1
> >         If .Item(lngX).Name Like "*" & lastModule & "_*" Then
> >             Debug.Print .Item(lngX).Name & " deleted."
> >             DoCmd.DeleteObject acForm, .Item(lngX).Name
> >         End If
> >     Next lngX
> > End With
> > '----- end of code ---

> > This just worked for me in a test.

> > --
> > Dirk Goldgar, MS Access MVP
> > www.datagnostics.com

> > (please reply to the newsgroup)



> > > It still gave the same error, Dirk.

> > > --
> > > TIA.
> > > Good Luck.
> > > Jeff R.



> > > > I'm just speculating, but I wonder if you can't delete the form
> > while
> > > > you have a reference to it in the "doc" object variable.  You
> > might
> > > > try setting doc = Nothing before deleting;  something like this:

> > > > Dim strDocName As String

> > > > Set dbs = CurrentDb()
> > > >     With dbs.Containers!Forms
> > > >         For Each doc In .Documents
> > > >             If doc.NAME Like "*" & lastModule & "_*" Then
> > > >                 strDocName = doc.Name
> > > >                 Set doc = Nothing
> > > >                 Debug.Print strDocName & " deleted."
> > > >                 DoCmd.DeleteObject acForm, strDocName
> > > >             End If
> > > >         Next doc
> > > >     End With

> > > > I'm curious to know if this fixes the problem.

> > > > --
> > > > Dirk Goldgar, MS Access MVP
> > > > www.datagnostics.com

> > > > (please reply to the newsgroup)



> > > > > I receive this error:

> > > > > 29068 - Form1 cannot complete this operation. You must stop the
> > code
> > > > and try
> > > > > again.

> > > > > Here is the code where the error occurs:
> > > > > ***BEGIN CODE***
> > > > > Set dbs = CurrentDb()
> > > > >     With dbs.Containers!Forms
> > > > >         For Each doc In .Documents
> > > > >             If doc.NAME Like "*" & lastModule & "_*" Then
> > > > >                 Debug.Print doc.NAME & " deleted."
> > > > >                 DoCmd.DeleteObject acForm, doc.NAME <---Error
> > Occurs
> > > > >             End If
> > > > >         Next doc
> > > > >     End With
> > > > > ***END CODE***

> > > > > How can I stop this error from happening?
> > > > > I am trapping it right now.
> > > > > WinXP Pro and AccessXP
> > > > > --
> > > > > TIA.
> > > > > Good Luck.
> > > > > Jeff R.




Mon, 23 May 2005 02:36:44 GMT  
 What does this mean?
Hmm.  I trust your code will not be trying to delete the form on which
the code is running.  Did vMike's approach work?  Is any of the forms
you would be deleting open at the time the code is running?  Are there
open queries that make reference to controls on those forms?

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


Quote:
> Well Dirk,
>     I made the changes, corrected the DB corruption and I'm still
receiving
> the same error.
> 29068 - Form1 cannot complete this operation. You must stop the code
and try
> again.

> --
> HTH.
> Good Luck.
> Jeff R.



> > Thanks for the info Dirk. But now I have another problem and
unable to
> test.
> > Posted in this same newsgroup (Title: Help!!!! Sudden Corruption?)

> > --
> > TKS.
> > Good Luck.
> > Jeff R.



> > > Actually, it occurs to me now that you may be running into the
old
> > > "deleting items from a collection while iterating through the
> > > collection using For Each ... Next" problem.  Try it like this:

> > > '----- start of code ---
> > > Dim dbs As DAO.Database
> > > Dim lngX As Long

> > > Set dbs = CurrentDb()
> > > With dbs.Containers("Forms").Documents
> > >     For lngX = .Count - 1 To 0 Step -1
> > >         If .Item(lngX).Name Like "*" & lastModule & "_*" Then
> > >             Debug.Print .Item(lngX).Name & " deleted."
> > >             DoCmd.DeleteObject acForm, .Item(lngX).Name
> > >         End If
> > >     Next lngX
> > > End With
> > > '----- end of code ---

> > > This just worked for me in a test.

> > > --
> > > Dirk Goldgar, MS Access MVP
> > > www.datagnostics.com

> > > (please reply to the newsgroup)



> > > > It still gave the same error, Dirk.

> > > > --
> > > > TIA.
> > > > Good Luck.
> > > > Jeff R.



> > > > > I'm just speculating, but I wonder if you can't delete the
form
> > > while
> > > > > you have a reference to it in the "doc" object variable.
You
> > > might
> > > > > try setting doc = Nothing before deleting;  something like
this:

> > > > > Dim strDocName As String

> > > > > Set dbs = CurrentDb()
> > > > >     With dbs.Containers!Forms
> > > > >         For Each doc In .Documents
> > > > >             If doc.NAME Like "*" & lastModule & "_*" Then
> > > > >                 strDocName = doc.Name
> > > > >                 Set doc = Nothing
> > > > >                 Debug.Print strDocName & " deleted."
> > > > >                 DoCmd.DeleteObject acForm, strDocName
> > > > >             End If
> > > > >         Next doc
> > > > >     End With

> > > > > I'm curious to know if this fixes the problem.

> > > > > --
> > > > > Dirk Goldgar, MS Access MVP
> > > > > www.datagnostics.com

> > > > > (please reply to the newsgroup)



> > > > > > I receive this error:

> > > > > > 29068 - Form1 cannot complete this operation. You must
stop the
> > > code
> > > > > and try
> > > > > > again.

> > > > > > Here is the code where the error occurs:
> > > > > > ***BEGIN CODE***
> > > > > > Set dbs = CurrentDb()
> > > > > >     With dbs.Containers!Forms
> > > > > >         For Each doc In .Documents
> > > > > >             If doc.NAME Like "*" & lastModule & "_*" Then
> > > > > >                 Debug.Print doc.NAME & " deleted."
> > > > > >                 DoCmd.DeleteObject acForm, doc.NAME
<---Error
> > > Occurs
> > > > > >             End If
> > > > > >         Next doc
> > > > > >     End With
> > > > > > ***END CODE***

> > > > > > How can I stop this error from happening?
> > > > > > I am trapping it right now.
> > > > > > WinXP Pro and AccessXP
> > > > > > --
> > > > > > TIA.
> > > > > > Good Luck.
> > > > > > Jeff R.




Mon, 23 May 2005 02:48:28 GMT  
 What does this mean?
The object does get deleted but the error message is what bothers me.
This only deletes forms copied from another db.
None of the forms should be open at time of deletion.
Nor are any queries open or running.

Does closing a form unload it?
--
HTH.
Good Luck.
Jeff R.


Quote:
> Hmm.  I trust your code will not be trying to delete the form on which
> the code is running.  Did vMike's approach work?  Is any of the forms
> you would be deleting open at the time the code is running?  Are there
> open queries that make reference to controls on those forms?

> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com

> (please reply to the newsgroup)



> > Well Dirk,
> >     I made the changes, corrected the DB corruption and I'm still
> receiving
> > the same error.
> > 29068 - Form1 cannot complete this operation. You must stop the code
> and try
> > again.

> > --
> > HTH.
> > Good Luck.
> > Jeff R.



> > > Thanks for the info Dirk. But now I have another problem and
> unable to
> > test.
> > > Posted in this same newsgroup (Title: Help!!!! Sudden Corruption?)

> > > --
> > > TKS.
> > > Good Luck.
> > > Jeff R.



> > > > Actually, it occurs to me now that you may be running into the
> old
> > > > "deleting items from a collection while iterating through the
> > > > collection using For Each ... Next" problem.  Try it like this:

> > > > '----- start of code ---
> > > > Dim dbs As DAO.Database
> > > > Dim lngX As Long

> > > > Set dbs = CurrentDb()
> > > > With dbs.Containers("Forms").Documents
> > > >     For lngX = .Count - 1 To 0 Step -1
> > > >         If .Item(lngX).Name Like "*" & lastModule & "_*" Then
> > > >             Debug.Print .Item(lngX).Name & " deleted."
> > > >             DoCmd.DeleteObject acForm, .Item(lngX).Name
> > > >         End If
> > > >     Next lngX
> > > > End With
> > > > '----- end of code ---

> > > > This just worked for me in a test.

> > > > --
> > > > Dirk Goldgar, MS Access MVP
> > > > www.datagnostics.com

> > > > (please reply to the newsgroup)



> > > > > It still gave the same error, Dirk.

> > > > > --
> > > > > TIA.
> > > > > Good Luck.
> > > > > Jeff R.



> > > > > > I'm just speculating, but I wonder if you can't delete the
> form
> > > > while
> > > > > > you have a reference to it in the "doc" object variable.
> You
> > > > might
> > > > > > try setting doc = Nothing before deleting;  something like
> this:

> > > > > > Dim strDocName As String

> > > > > > Set dbs = CurrentDb()
> > > > > >     With dbs.Containers!Forms
> > > > > >         For Each doc In .Documents
> > > > > >             If doc.NAME Like "*" & lastModule & "_*" Then
> > > > > >                 strDocName = doc.Name
> > > > > >                 Set doc = Nothing
> > > > > >                 Debug.Print strDocName & " deleted."
> > > > > >                 DoCmd.DeleteObject acForm, strDocName
> > > > > >             End If
> > > > > >         Next doc
> > > > > >     End With

> > > > > > I'm curious to know if this fixes the problem.

> > > > > > --
> > > > > > Dirk Goldgar, MS Access MVP
> > > > > > www.datagnostics.com

> > > > > > (please reply to the newsgroup)



> > > > > > > I receive this error:

> > > > > > > 29068 - Form1 cannot complete this operation. You must
> stop the
> > > > code
> > > > > > and try
> > > > > > > again.

> > > > > > > Here is the code where the error occurs:
> > > > > > > ***BEGIN CODE***
> > > > > > > Set dbs = CurrentDb()
> > > > > > >     With dbs.Containers!Forms
> > > > > > >         For Each doc In .Documents
> > > > > > >             If doc.NAME Like "*" & lastModule & "_*" Then
> > > > > > >                 Debug.Print doc.NAME & " deleted."
> > > > > > >                 DoCmd.DeleteObject acForm, doc.NAME
> <---Error
> > > > Occurs
> > > > > > >             End If
> > > > > > >         Next doc
> > > > > > >     End With
> > > > > > > ***END CODE***

> > > > > > > How can I stop this error from happening?
> > > > > > > I am trapping it right now.
> > > > > > > WinXP Pro and AccessXP
> > > > > > > --
> > > > > > > TIA.
> > > > > > > Good Luck.
> > > > > > > Jeff R.




Mon, 23 May 2005 03:01:16 GMT  
 What does this mean?

Quote:
> The object does get deleted but the error message is what bothers
me.
> This only deletes forms copied from another db.
> None of the forms should be open at time of deletion.
> Nor are any queries open or running.

> Does closing a form unload it?

I'm not sure what you mean by your question.  Closing a form does
unload it from memory.

You may want to try refreshing the collection before running the code:

    With dbs.Containers("Forms").Documents
        .Refresh
        ' ... rest of code

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)



Mon, 23 May 2005 03:15:39 GMT  
 What does this mean?
I tested my code and it does infact work. You only get the error if the form
you want to delete it is the current doc in the for... next loop, so by
setting the last doc name to an independant variable and then going to the
next doc you solve the problem. My guess is that if you delete the form you
are referring to in the the loop then VBA or access doesn't know which form
is next. Just a hunch.


Quote:
> Hmm.  I trust your code will not be trying to delete the form on which
> the code is running.  Did vMike's approach work?  Is any of the forms
> you would be deleting open at the time the code is running?  Are there
> open queries that make reference to controls on those forms?

> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com

> (please reply to the newsgroup)



> > Well Dirk,
> >     I made the changes, corrected the DB corruption and I'm still
> receiving
> > the same error.
> > 29068 - Form1 cannot complete this operation. You must stop the code
> and try
> > again.

> > --
> > HTH.
> > Good Luck.
> > Jeff R.



> > > Thanks for the info Dirk. But now I have another problem and
> unable to
> > test.
> > > Posted in this same newsgroup (Title: Help!!!! Sudden Corruption?)

> > > --
> > > TKS.
> > > Good Luck.
> > > Jeff R.



> > > > Actually, it occurs to me now that you may be running into the
> old
> > > > "deleting items from a collection while iterating through the
> > > > collection using For Each ... Next" problem.  Try it like this:

> > > > '----- start of code ---
> > > > Dim dbs As DAO.Database
> > > > Dim lngX As Long

> > > > Set dbs = CurrentDb()
> > > > With dbs.Containers("Forms").Documents
> > > >     For lngX = .Count - 1 To 0 Step -1
> > > >         If .Item(lngX).Name Like "*" & lastModule & "_*" Then
> > > >             Debug.Print .Item(lngX).Name & " deleted."
> > > >             DoCmd.DeleteObject acForm, .Item(lngX).Name
> > > >         End If
> > > >     Next lngX
> > > > End With
> > > > '----- end of code ---

> > > > This just worked for me in a test.

> > > > --
> > > > Dirk Goldgar, MS Access MVP
> > > > www.datagnostics.com

> > > > (please reply to the newsgroup)



> > > > > It still gave the same error, Dirk.

> > > > > --
> > > > > TIA.
> > > > > Good Luck.
> > > > > Jeff R.



> > > > > > I'm just speculating, but I wonder if you can't delete the
> form
> > > > while
> > > > > > you have a reference to it in the "doc" object variable.
> You
> > > > might
> > > > > > try setting doc = Nothing before deleting;  something like
> this:

> > > > > > Dim strDocName As String

> > > > > > Set dbs = CurrentDb()
> > > > > >     With dbs.Containers!Forms
> > > > > >         For Each doc In .Documents
> > > > > >             If doc.NAME Like "*" & lastModule & "_*" Then
> > > > > >                 strDocName = doc.Name
> > > > > >                 Set doc = Nothing
> > > > > >                 Debug.Print strDocName & " deleted."
> > > > > >                 DoCmd.DeleteObject acForm, strDocName
> > > > > >             End If
> > > > > >         Next doc
> > > > > >     End With

> > > > > > I'm curious to know if this fixes the problem.

> > > > > > --
> > > > > > Dirk Goldgar, MS Access MVP
> > > > > > www.datagnostics.com

> > > > > > (please reply to the newsgroup)



> > > > > > > I receive this error:

> > > > > > > 29068 - Form1 cannot complete this operation. You must
> stop the
> > > > code
> > > > > > and try
> > > > > > > again.

> > > > > > > Here is the code where the error occurs:
> > > > > > > ***BEGIN CODE***
> > > > > > > Set dbs = CurrentDb()
> > > > > > >     With dbs.Containers!Forms
> > > > > > >         For Each doc In .Documents
> > > > > > >             If doc.NAME Like "*" & lastModule & "_*" Then
> > > > > > >                 Debug.Print doc.NAME & " deleted."
> > > > > > >                 DoCmd.DeleteObject acForm, doc.NAME
> <---Error
> > > > Occurs
> > > > > > >             End If
> > > > > > >         Next doc
> > > > > > >     End With
> > > > > > > ***END CODE***

> > > > > > > How can I stop this error from happening?
> > > > > > > I am trapping it right now.
> > > > > > > WinXP Pro and AccessXP
> > > > > > > --
> > > > > > > TIA.
> > > > > > > Good Luck.
> > > > > > > Jeff R.




Mon, 23 May 2005 03:29:50 GMT  
 What does this mean?
It's plausible, all right.  But the code I last posted also works --
for me, but Jeff says it doesn't for him.  I'd certainly recommend he
try your approach, if he hasn't already.

Another approach might be to build an array or collection of the form
names to be deleted, and then just pass through that array or
collection once to delete each object.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


Quote:
> I tested my code and it does infact work. You only get the error if
the form
> you want to delete it is the current doc in the for... next loop, so
by
> setting the last doc name to an independant variable and then going
to the
> next doc you solve the problem. My guess is that if you delete the
form you
> are referring to in the the loop then VBA or access doesn't know
which form
> is next. Just a hunch.



> > Hmm.  I trust your code will not be trying to delete the form on
which
> > the code is running.  Did vMike's approach work?  Is any of the
forms
> > you would be deleting open at the time the code is running?  Are
there
> > open queries that make reference to controls on those forms?

> > --
> > Dirk Goldgar, MS Access MVP
> > www.datagnostics.com

> > (please reply to the newsgroup)



> > > Well Dirk,
> > >     I made the changes, corrected the DB corruption and I'm
still
> > receiving
> > > the same error.
> > > 29068 - Form1 cannot complete this operation. You must stop the
code
> > and try
> > > again.

> > > --
> > > HTH.
> > > Good Luck.
> > > Jeff R.



> > > > Thanks for the info Dirk. But now I have another problem and
> > unable to
> > > test.
> > > > Posted in this same newsgroup (Title: Help!!!! Sudden
Corruption?)

> > > > --
> > > > TKS.
> > > > Good Luck.
> > > > Jeff R.



> > > > > Actually, it occurs to me now that you may be running into
the
> > old
> > > > > "deleting items from a collection while iterating through
the
> > > > > collection using For Each ... Next" problem.  Try it like
this:

> > > > > '----- start of code ---
> > > > > Dim dbs As DAO.Database
> > > > > Dim lngX As Long

> > > > > Set dbs = CurrentDb()
> > > > > With dbs.Containers("Forms").Documents
> > > > >     For lngX = .Count - 1 To 0 Step -1
> > > > >         If .Item(lngX).Name Like "*" & lastModule & "_*"
Then
> > > > >             Debug.Print .Item(lngX).Name & " deleted."
> > > > >             DoCmd.DeleteObject acForm, .Item(lngX).Name
> > > > >         End If
> > > > >     Next lngX
> > > > > End With
> > > > > '----- end of code ---

> > > > > This just worked for me in a test.

> > > > > --
> > > > > Dirk Goldgar, MS Access MVP
> > > > > www.datagnostics.com

> > > > > (please reply to the newsgroup)



> > > > > > It still gave the same error, Dirk.

> > > > > > --
> > > > > > TIA.
> > > > > > Good Luck.
> > > > > > Jeff R.


message

> > > > > > > I'm just speculating, but I wonder if you can't delete
the
> > form
> > > > > while
> > > > > > > you have a reference to it in the "doc" object variable.
> > You
> > > > > might
> > > > > > > try setting doc = Nothing before deleting;  something
like
> > this:

> > > > > > > Dim strDocName As String

> > > > > > > Set dbs = CurrentDb()
> > > > > > >     With dbs.Containers!Forms
> > > > > > >         For Each doc In .Documents
> > > > > > >             If doc.NAME Like "*" & lastModule & "_*"
Then
> > > > > > >                 strDocName = doc.Name
> > > > > > >                 Set doc = Nothing
> > > > > > >                 Debug.Print strDocName & " deleted."
> > > > > > >                 DoCmd.DeleteObject acForm, strDocName
> > > > > > >             End If
> > > > > > >         Next doc
> > > > > > >     End With

> > > > > > > I'm curious to know if this fixes the problem.

> > > > > > > --
> > > > > > > Dirk Goldgar, MS Access MVP
> > > > > > > www.datagnostics.com

> > > > > > > (please reply to the newsgroup)



> > > > > > > > I receive this error:

> > > > > > > > 29068 - Form1 cannot complete this operation. You must
> > stop the
> > > > > code
> > > > > > > and try
> > > > > > > > again.

> > > > > > > > Here is the code where the error occurs:
> > > > > > > > ***BEGIN CODE***
> > > > > > > > Set dbs = CurrentDb()
> > > > > > > >     With dbs.Containers!Forms
> > > > > > > >         For Each doc In .Documents
> > > > > > > >             If doc.NAME Like "*" & lastModule & "_*"
Then
> > > > > > > >                 Debug.Print doc.NAME & " deleted."
> > > > > > > >                 DoCmd.DeleteObject acForm, doc.NAME
> > <---Error
> > > > > Occurs
> > > > > > > >             End If
> > > > > > > >         Next doc
> > > > > > > >     End With
> > > > > > > > ***END CODE***

> > > > > > > > How can I stop this error from happening?
> > > > > > > > I am trapping it right now.
> > > > > > > > WinXP Pro and AccessXP
> > > > > > > > --
> > > > > > > > TIA.
> > > > > > > > Good Luck.
> > > > > > > > Jeff R.




Mon, 23 May 2005 04:33:43 GMT  
 What does this mean?
Just found something odd. I only get the error on some forms.

Here is a sample of the debug:

sfrmCA_PEB deleted.
sfrmCA_PayCertRetain deleted.
29068 - B&V Multi-Function Console cannot complete this operation. You must
stop the code and try again.
sfrmCA_PayCertFooter deleted.
sfrmCA_PayCertAddress deleted.
29068 - B&V Multi-Function Console cannot complete this operation. You must
stop the code and try again.

--
HTH.
Good Luck.
Jeff R.


Quote:
> It's plausible, all right.  But the code I last posted also works --
> for me, but Jeff says it doesn't for him.  I'd certainly recommend he
> try your approach, if he hasn't already.

> Another approach might be to build an array or collection of the form
> names to be deleted, and then just pass through that array or
> collection once to delete each object.

> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com

> (please reply to the newsgroup)



> > I tested my code and it does infact work. You only get the error if
> the form
> > you want to delete it is the current doc in the for... next loop, so
> by
> > setting the last doc name to an independant variable and then going
> to the
> > next doc you solve the problem. My guess is that if you delete the
> form you
> > are referring to in the the loop then VBA or access doesn't know
> which form
> > is next. Just a hunch.



> > > Hmm.  I trust your code will not be trying to delete the form on
> which
> > > the code is running.  Did vMike's approach work?  Is any of the
> forms
> > > you would be deleting open at the time the code is running?  Are
> there
> > > open queries that make reference to controls on those forms?

> > > --
> > > Dirk Goldgar, MS Access MVP
> > > www.datagnostics.com

> > > (please reply to the newsgroup)



> > > > Well Dirk,
> > > >     I made the changes, corrected the DB corruption and I'm
> still
> > > receiving
> > > > the same error.
> > > > 29068 - Form1 cannot complete this operation. You must stop the
> code
> > > and try
> > > > again.

> > > > --
> > > > HTH.
> > > > Good Luck.
> > > > Jeff R.



> > > > > Thanks for the info Dirk. But now I have another problem and
> > > unable to
> > > > test.
> > > > > Posted in this same newsgroup (Title: Help!!!! Sudden
> Corruption?)

> > > > > --
> > > > > TKS.
> > > > > Good Luck.
> > > > > Jeff R.



> > > > > > Actually, it occurs to me now that you may be running into
> the
> > > old
> > > > > > "deleting items from a collection while iterating through
> the
> > > > > > collection using For Each ... Next" problem.  Try it like
> this:

> > > > > > '----- start of code ---
> > > > > > Dim dbs As DAO.Database
> > > > > > Dim lngX As Long

> > > > > > Set dbs = CurrentDb()
> > > > > > With dbs.Containers("Forms").Documents
> > > > > >     For lngX = .Count - 1 To 0 Step -1
> > > > > >         If .Item(lngX).Name Like "*" & lastModule & "_*"
> Then
> > > > > >             Debug.Print .Item(lngX).Name & " deleted."
> > > > > >             DoCmd.DeleteObject acForm, .Item(lngX).Name
> > > > > >         End If
> > > > > >     Next lngX
> > > > > > End With
> > > > > > '----- end of code ---

> > > > > > This just worked for me in a test.

> > > > > > --
> > > > > > Dirk Goldgar, MS Access MVP
> > > > > > www.datagnostics.com

> > > > > > (please reply to the newsgroup)



> > > > > > > It still gave the same error, Dirk.

> > > > > > > --
> > > > > > > TIA.
> > > > > > > Good Luck.
> > > > > > > Jeff R.


> message

> > > > > > > > I'm just speculating, but I wonder if you can't delete
> the
> > > form
> > > > > > while
> > > > > > > > you have a reference to it in the "doc" object variable.
> > > You
> > > > > > might
> > > > > > > > try setting doc = Nothing before deleting;  something
> like
> > > this:

> > > > > > > > Dim strDocName As String

> > > > > > > > Set dbs = CurrentDb()
> > > > > > > >     With dbs.Containers!Forms
> > > > > > > >         For Each doc In .Documents
> > > > > > > >             If doc.NAME Like "*" & lastModule & "_*"
> Then
> > > > > > > >                 strDocName = doc.Name
> > > > > > > >                 Set doc = Nothing
> > > > > > > >                 Debug.Print strDocName & " deleted."
> > > > > > > >                 DoCmd.DeleteObject acForm, strDocName
> > > > > > > >             End If
> > > > > > > >         Next doc
> > > > > > > >     End With

> > > > > > > > I'm curious to know if this fixes the problem.

> > > > > > > > --
> > > > > > > > Dirk Goldgar, MS Access MVP
> > > > > > > > www.datagnostics.com

> > > > > > > > (please reply to the newsgroup)



> > > > > > > > > I receive this error:

> > > > > > > > > 29068 - Form1 cannot complete this operation. You must
> > > stop the
> > > > > > code
> > > > > > > > and try
> > > > > > > > > again.

> > > > > > > > > Here is the code where the error occurs:
> > > > > > > > > ***BEGIN CODE***
> > > > > > > > > Set dbs = CurrentDb()
> > > > > > > > >     With dbs.Containers!Forms
> > > > > > > > >         For Each doc In .Documents
> > > > > > > > >             If doc.NAME Like "*" & lastModule & "_*"
> Then
> > > > > > > > >                 Debug.Print doc.NAME & " deleted."
> > > > > > > > >                 DoCmd.DeleteObject acForm, doc.NAME
> > > <---Error
> > > > > > Occurs
> > > > > > > > >             End If
> > > > > > > > >         Next doc
> > > > > > > > >     End With
> > > > > > > > > ***END CODE***

> > > > > > > > > How can I stop this error from happening?
> > > > > > > > > I am trapping it right now.
> > > > > > > > > WinXP Pro and AccessXP
> > > > > > > > > --
> > > > > > > > > TIA.
> > > > > > > > > Good Luck.
> > > > > > > > > Jeff R.




Mon, 23 May 2005 05:14:32 GMT  
 What does this mean?
So how do the forms that cause the error different from the ones that
don't?  Is it that some have code modules and some don't?

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


Quote:
> Just found something odd. I only get the error on some forms.

> Here is a sample of the debug:

> sfrmCA_PEB deleted.
> sfrmCA_PayCertRetain deleted.
> 29068 - B&V Multi-Function Console cannot complete this operation.
You must
> stop the code and try again.
> sfrmCA_PayCertFooter deleted.
> sfrmCA_PayCertAddress deleted.
> 29068 - B&V Multi-Function Console cannot complete this operation.
You must
> stop the code and try again.

> --
> HTH.
> Good Luck.
> Jeff R.



> > It's plausible, all right.  But the code I last posted also
works --
> > for me, but Jeff says it doesn't for him.  I'd certainly recommend
he
> > try your approach, if he hasn't already.

> > Another approach might be to build an array or collection of the
form
> > names to be deleted, and then just pass through that array or
> > collection once to delete each object.

> > --
> > Dirk Goldgar, MS Access MVP
> > www.datagnostics.com

> > (please reply to the newsgroup)



> > > I tested my code and it does infact work. You only get the error
if
> > the form
> > > you want to delete it is the current doc in the for... next
loop, so
> > by
> > > setting the last doc name to an independant variable and then
going
> > to the
> > > next doc you solve the problem. My guess is that if you delete
the
> > form you
> > > are referring to in the the loop then VBA or access doesn't know
> > which form
> > > is next. Just a hunch.



> > > > Hmm.  I trust your code will not be trying to delete the form
on
> > which
> > > > the code is running.  Did vMike's approach work?  Is any of
the
> > forms
> > > > you would be deleting open at the time the code is running?
Are
> > there
> > > > open queries that make reference to controls on those forms?

> > > > --
> > > > Dirk Goldgar, MS Access MVP
> > > > www.datagnostics.com

> > > > (please reply to the newsgroup)



> > > > > Well Dirk,
> > > > >     I made the changes, corrected the DB corruption and I'm
> > still
> > > > receiving
> > > > > the same error.
> > > > > 29068 - Form1 cannot complete this operation. You must stop
the
> > code
> > > > and try
> > > > > again.

> > > > > --
> > > > > HTH.
> > > > > Good Luck.
> > > > > Jeff R.



> > > > > > Thanks for the info Dirk. But now I have another problem
and
> > > > unable to
> > > > > test.
> > > > > > Posted in this same newsgroup (Title: Help!!!! Sudden
> > Corruption?)

> > > > > > --
> > > > > > TKS.
> > > > > > Good Luck.
> > > > > > Jeff R.


message

> > > > > > > Actually, it occurs to me now that you may be running
into
> > the
> > > > old
> > > > > > > "deleting items from a collection while iterating
through
> > the
> > > > > > > collection using For Each ... Next" problem.  Try it
like
> > this:

> > > > > > > '----- start of code ---
> > > > > > > Dim dbs As DAO.Database
> > > > > > > Dim lngX As Long

> > > > > > > Set dbs = CurrentDb()
> > > > > > > With dbs.Containers("Forms").Documents
> > > > > > >     For lngX = .Count - 1 To 0 Step -1
> > > > > > >         If .Item(lngX).Name Like "*" & lastModule & "_*"
> > Then
> > > > > > >             Debug.Print .Item(lngX).Name & " deleted."
> > > > > > >             DoCmd.DeleteObject acForm, .Item(lngX).Name
> > > > > > >         End If
> > > > > > >     Next lngX
> > > > > > > End With
> > > > > > > '----- end of code ---

> > > > > > > This just worked for me in a test.

> > > > > > > --
> > > > > > > Dirk Goldgar, MS Access MVP
> > > > > > > www.datagnostics.com

> > > > > > > (please reply to the newsgroup)



> > > > > > > > It still gave the same error, Dirk.

> > > > > > > > --
> > > > > > > > TIA.
> > > > > > > > Good Luck.
> > > > > > > > Jeff R.


> > message

> > > > > > > > > I'm just speculating, but I wonder if you can't
delete
> > the
> > > > form
> > > > > > > while
> > > > > > > > > you have a reference to it in the "doc" object
variable.
> > > > You
> > > > > > > might
> > > > > > > > > try setting doc = Nothing before deleting;
something
> > like
> > > > this:

> > > > > > > > > Dim strDocName As String

> > > > > > > > > Set dbs = CurrentDb()
> > > > > > > > >     With dbs.Containers!Forms
> > > > > > > > >         For Each doc In .Documents
> > > > > > > > >             If doc.NAME Like "*" & lastModule & "_*"
> > Then
> > > > > > > > >                 strDocName = doc.Name
> > > > > > > > >                 Set doc = Nothing
> > > > > > > > >                 Debug.Print strDocName & " deleted."
> > > > > > > > >                 DoCmd.DeleteObject acForm,
strDocName
> > > > > > > > >             End If
> > > > > > > > >         Next doc
> > > > > > > > >     End With

> > > > > > > > > I'm curious to know if this fixes the problem.

> > > > > > > > > --
> > > > > > > > > Dirk Goldgar, MS Access MVP
> > > > > > > > > www.datagnostics.com

> > > > > > > > > (please reply to the newsgroup)



> > > > > > > > > > I receive this error:

> > > > > > > > > > 29068 - Form1 cannot complete this operation. You
must
> > > > stop the
> > > > > > > code
> > > > > > > > > and try
> > > > > > > > > > again.

> > > > > > > > > > Here is the code where the error occurs:
> > > > > > > > > > ***BEGIN CODE***
> > > > > > > > > > Set dbs = CurrentDb()
> > > > > > > > > >     With dbs.Containers!Forms
> > > > > > > > > >         For Each doc In .Documents
> > > > > > > > > >             If doc.NAME Like "*" & lastModule &
"_*"
> > Then
> > > > > > > > > >                 Debug.Print doc.NAME & " deleted."
> > > > > > > > > >                 DoCmd.DeleteObject acForm,
doc.NAME
> > > > <---Error
> > > > > > > Occurs
> > > > > > > > > >             End If
> > > > > > > > > >         Next doc
> > > > > > > > > >     End With
> > > > > > > > > > ***END CODE***

> > > > > > > > > > How can I stop this error from happening?
> > > > > > > > > > I am trapping it right now.
> > > > > > > > > > WinXP Pro and AccessXP
> > > > > > > > > > --
> > > > > > > > > > TIA.
> > > > > > > > > > Good Luck.
> > > > > > > > > > Jeff R.




Mon, 23 May 2005 13:28:35 GMT  
 
 [ 18 post ]  Go to page: [1] [2]

 Relevant Pages 

1. ADO thinks DBMS is done, but DBMS ain't done

2. Geometric Mean?

3. What does this error mean?

4. SQL Statement What does it mean?

5. Meaning of error messages

6. Not sure what this error means. (Error 3426)

7. how to add a new dataset from excel to access by means of vba

8. The Back Admin means zero administration!!!

9. EFGLS...What does this stuff mean

10. what's this meaning?

11. EFGLS...What does this stuff mean

12. Delete a field from table by means of VBA function

 

 
Powered by phpBB® Forum Software