Question

I've been developing a program in excel vba for some time now with no errors. Today however, adter only commenting out something outside of a sub, all of my functions now throw a Function call on left-hand side of assignment must return variant or object error error. See a sample below:

Public Function fGetEmployees() As Variant()

Dim oDB As ADODB.Connection
Dim oCM As ADODB.Command
Dim oRS As ADODB.Recordset
Dim strSQL As String

On Error GoTo Err:

strSQL = "SELECT StaffId, FirstName, LastName " & _
        "FROM ptqEmployees"

Set oDB = New ADODB.Connection
oDB.Open gcConn
Set oCM = New ADODB.Command

With oCM
    .ActiveConnection = oDB
    .CommandText = strSQL
    .CommandType = adCmdText
    Set oRS = .Execute
End With

fGetEmployees = oRS.GetRows()

oRS.Close
Set oRS = Nothing
oDB.Close
Set oRS = Nothing

Exit Function

Err:
    Call fLogDBError(Err.Number, Err.Description, 4)

End Function

The error gets thrown on line: fGetEmployees = oRS.GetRows()

As said this has been functioning with no issues for sometime now. There's no option to debug either.

Can anyone assist with what the issue is?

Was it helpful?

Solution

Very strange but I exported the module and then imported it and it's working fine now.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top