You need to use the set command. This is because the function is supposed to return an object, therefore you need to use "Set QueryResult = ado"
I have used this exact principle in my program, here is the code.
Code:
Public Function RecordsetEx(ByVal Source As String, _
conn As Object, _
Optional ByVal CursorType As CursorTypeEnum = adOpenUnspecified, _
Optional ByVal LockType As LockTypeEnum = adLockUnspecified, _
Optional ByVal Options As Long = -1) As Object
If conn Is Nothing Then
MsgBox "Nothing can be done because an active _
connection object has not been supplied.", vbInformation
Exit Function
End If
Set RecordsetEx = New ADODB.Recordset
RecordsetEx.Open Source, conn, CursorType, LockType, Options
End Function,