I have the following code. The intent is to have this utility class that I use to hold all my database work and just return populated ADODB.RecordSet objects. I am getting errors. What am I doing wrong?
Public Property Get RecordSetCustomers() As ADODB.Recordset
m_myDB.BuildConfig
Dim cmd As New ADODB.Command
Dim strSQL As String
strSQL = "SELECT * FROM vw_customers"
cmd.CommandType = ADODB.CommandTypeEnum.adCmdText
cmd.ActiveConnection = m_myDB.DbConnection
cmd.CommandText = strSQL
Dim rs As New ADODB.Recordset
Set rs = New ADODB.Recordset
Set rs = cmd.Execute
RecordSetCustomers = rs
End Property
The m_myDB is an object/class that holds all my database configuration/connection params.
The error I am receiving is: ‘Compile Error: Invalid use of property’
I tried converting this to a function with same result.
VBA syntax requires the keyword ‘set’ for object reference assignments. See http://roymacleanvba.wordpress.com/2009/05/08/set-keyword/