Llamada a la función en el lado izquierdo de la asignación debe devolver variante o error de objeto

StackOverflow https://stackoverflow.com//questions/23063137

Pregunta

He sido el desarrollo de un programa en excel vba desde hace algún tiempo, sin errores.Hoy, sin embargo, adter solo comentar algo fuera de un sub, todos mis funciones ahora lanzan un Function call on left-hand side of assignment must return variant or object error error.Ver un ejemplo a continuación:

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

El error se tira en línea:fGetEmployees = oRS.GetRows()

Como dijo esto ha estado funcionando sin problemas por algún tiempo ahora.No hay ninguna opción para depurar bien.

Puede alguien ayudar con cuál es el problema?

¿Fue útil?

Solución

Muy extraño, pero he exportado el módulo y, a continuación, importados y se está trabajando bien ahora.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top