You're right: I intended the loop to be Step -1.
For your example of:
Dim ctl As Control
you should not have to explicitly use:
Set ctl = Nothing
at the end of that procedure. Having said that, I do it anyway: guess I just
don't trust Access to release all objects.
You also asked:
Am I wrong to assume that object variables only exist if the
module in which they exist is called?
It's a bit more involved than that. Basically, if you never open a form,
then it's module is not loaded into memory, and so its objects are not
instantiated. However, there are cases where that may not be true. For
example, this could cause Form1's module to be loaded:
Call Form_Form1.MyProcedure
Also, passing an object from one procedure to another can change its
lifetime. Using the Static keyword can change its lifetime.
Now to this reply. Good: you have isolated what triggers the problem. And
you are, in fact, passing an object to LoadForm(). If LoadForm() is in a
different module, that could be the issue.
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Keith" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Again:
>
> Forgot to mention, this is Access 2003.
>
> As I continue to test, I've noticed that closing from the initial menu
> form does completely close Access. However, any menu item I choose
> from one of three list boxes cause Access not to close when I return
> to the main menu and click exit. Is there anything about this code
> that would cause that:
>
> Private Sub lstBrowse_AfterUpdate()
> lstOverviews = Null
> lstCreateNew = Null
> LoadForm (Forms!frmMenuMain.lstBrowse)
> End Sub
>
> Public Sub LoadForm(MenuList As ListBox)
> Dim strArg As String
> Dim lngMode As Long
>
> Select Case CLng(MenuList.Column(2))
> Case 0 'Add mode
> strArg = "Add"
> lngMode = 0
> Case 1 'Edit mode
> strArg = "Edit"
> lngMode = 1
> Case 2 'Read only mode
> strArg = "Read"
> lngMode = 2
> Case Else
> End Select
>
> DoCmd.OpenForm MenuList.Column(1), acNormal, , , lngMode, , strArg
>
> End Sub
>
> On Jun 4, 1:26 am, "Allen Browne" <AllenBro...@SeeSig.Invalid> wrote:
>> Hi Keith. Some things to try:
>>
>> What version of Access is this?