Invalid Use of Property?

calendar_today Asked May 7, 2012
thumb_up 7 upvotes
history Updated April 16, 2026

Question posted 2012 ยท +3 upvotes

I am working with an Access database and it has a form and VBA behind it. It has been quite a while since I dabbled in VBA and my google-fu is failing me right now so bear with me.

I created a simple class, and I am getting a compile error:

Dim oRecordSet As ADODB.RecordSet
Public Property Get RecordSet() As ADODB.RecordSet
    RecordSet = oRecordSet '' error here
End Property

Public Property Let RecordSet(ByVal val As ADODB.RecordSet)
    RecordSet = val
End Property

I have a couple other identical properties (different names/variables, obviously) that compile just fine; their types are String and Integer.

What am I missing? Thanks!

Also a side note, when I am coding the intellisense shows ADODB.Recordset, but on autoformat (carriage return, compile, etc) it changes it to ADODB.RecordSet. Need I be worried?

Accepted answer +7 upvotes

It should be:

Public Property Get RecordSet() As ADODB.RecordSet
    Set RecordSet = oRecordSet '' error here
End Property

Top access-vba Q&A (6)

+7 upvotes ranks this answer #10 out of 12 access-vba solutions on this site .