backcountryprogrammer
Member
- Local time
- Yesterday, 23:35
- Joined
- Aug 10, 2024
- Messages
- 39
The NewEnum get property is causing trouble in some of my Collection wrapper classes I'm trying to write. It seems to work for me in some projects/classes but not in others. I think there's some serious bug here. If I step (F8) through the For-Next loop (in the places where it doesn't work for me) it then works, but when I run through it normally its causes Access to crash.
I've been trying to pinpoint for hours to find out what is triggering this but to no avail. Does anybody else have experienced this problem?
BTW: I know of and tried the /decompile /repair /compact switches.
I'm using Access v16.0 (64 bit).
Attached is a copy of the database. And here's the code. There's not much to see and as simple as possible.
Even if I create a fresh database project and import those files it crashes for me. Perhaps I'm doing something wrong and can't see i, but again it works when stepping (F8) through the loop which tells me this is an Access bug.
Some dummy class to add to the collection.
And here's the minimal custom collection.
I've been trying to pinpoint for hours to find out what is triggering this but to no avail. Does anybody else have experienced this problem?
BTW: I know of and tried the /decompile /repair /compact switches.
I'm using Access v16.0 (64 bit).
Attached is a copy of the database. And here's the code. There's not much to see and as simple as possible.
Even if I create a fresh database project and import those files it crashes for me. Perhaps I'm doing something wrong and can't see i, but again it works when stepping (F8) through the loop which tells me this is an Access bug.
Code:
Attribute VB_Name = "Module1"
Option Compare Database
Option Explicit
Dim Coll As New Class2
' This crashes when run (F5). However, when
' stepped (F8) through, it doesn't.
Sub Dump()
Dim o As Object
For Each o In Coll
Debug.Print ObjPtr(o)
Next
End Sub
' Add some object to the collection.
Sub AddSome()
Coll.Add New Class1
End Sub
Some dummy class to add to the collection.
Code:
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "Class1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Compare Database
Option Explicit
' Empty dummy, to keep it simple.
And here's the minimal custom collection.
Code:
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "Class2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Compare Database
Option Explicit
Private Coll As New Collection
Sub Add(ByVal Class2 As Class1)
Coll.Add Class2
End Sub
Property Get NewEnum() As IUnknown
Attribute NewEnum.VB_UserMemId = -4
Set NewEnum = Coll.[_NewEnum]
End Property
Attachments
Last edited: