Home Access an Collection within a form via VBA out of a Class-module
Reply: 0

Access an Collection within a form via VBA out of a Class-module

user1379
1#
user1379 Published in June 24, 2018, 3:24 am

I just like to reorder the VBA of a bunch of Forms in Access, doing all nearly the same. So I created a class clsPopup and I just want to pass some collections out of all this Forms into the class, so I can access their entries over there or in there or how ever.

I could pass the Form-element of the Popup to the class as I created a sub named Load in clsPopup like

Dim m_frm As Form  

sub Load(frm As Form)
    Set m_frm = frm
    debug.print m_frm.colSp("Name")
end sub

In the Form I tried

Dim m_clsPopup As clsPopup
Dim colSp As Collection

sub Form_Load()
    Set m_clsPopup = New clsPopup
    Set colSp = New Collection

    colSp.Add "SomeString", "Name"
    m_clsPopup.Load Me.Form

end sub

At this point I got the 2465 Runtime error in the line of m_clsPopup.Load Me.Form.

My main idea is, to just collect all the needed data within the Forms as collections and than I easily could work with them in the class.

Of course I thought of arrays, but collections seems so much more handy and I could avoid some terrible indexing.

Ahh, and it needs to work in Access 2010. Might that be the problem?

I feel like just a tiny pice of code is missing. Could anyone help to create nice code out of a masterpiece of redundancy?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.30884 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO