-
What's wrong with my code?????
[Originally posted by Bernie Kozlowski]
This code for some reason does not cycyle through all open forms.ÿ If I have more than 4 forms open, it always only closes three.ÿ Less than 4 forms open it always leaves the form I want open, plus one other.ÿ
Any Ideas???
Sub closeforms()
Dim frm As Form
ÿ If gpurpose = "Enter" Then
ÿ ÿ If frm.Name <> "frm_Main_entry_form" Then
ÿ ÿ ÿ ÿ For Each frm In Forms
ÿ ÿ ÿ ÿ ÿ ÿ DoCmd.Close acForm, frm.Name
ÿ ÿ ÿ ÿ ÿ ÿ Set frm = Nothing
ÿ ÿ ÿ ÿ Next
ÿ ÿ End If
ÿ Else
ÿ ÿ If gpurpose = "Edit" Then
ÿ ÿ ÿ ÿ For Each frm In Forms
ÿ ÿ ÿ ÿ ÿ ÿ If frm.Name <> "frm_Main_edit_form" Then
ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ DoCmd.Close acForm, frm.Name
ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ Set frm = Nothing
ÿ ÿ ÿ ÿ ÿ ÿ End If
ÿ ÿ ÿ ÿ Next
ÿ ÿ Else
ÿ ÿ ÿ ÿ For Each frm In Forms
ÿ ÿ ÿ ÿ ÿ ÿ If frm.Name <> "frm_Main_view_form" Then
ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ DoCmd.Close acForm, frm.Name
ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ Set frm = Nothing
ÿ ÿ ÿ ÿ ÿ ÿ End If
ÿ ÿ ÿ ÿ Next frm
ÿ ÿ End If
ÿ End If
ÿ ÿ
End Sub
-
Re:What's wrong with my code?????
[Originally posted by Greg DeBacker]
It would seem that everytime you close a form it is resetting the Forms collection to the new number of forms. The For Each loop is getting out of sync. I really haven't tested this idea. It is just a thought.
Grex
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks