L'appel de fonction sur le côté gauche de l'affectation doit renvoyer une erreur de variante ou d'objet

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

Question

Je développe un programme dans Excel VBA depuis un certain temps maintenant sans erreur.Aujourd'hui cependant, après avoir seulement commenté quelque chose en dehors d'un sous-marin, toutes mes fonctions lancent désormais un Function call on left-hand side of assignment must return variant or object error erreur.Voir un exemple ci-dessous :

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

L'erreur est renvoyée en ligne :fGetEmployees = oRS.GetRows()

Comme je l'ai dit, cela fonctionne sans problème depuis un certain temps maintenant.Il n'y a pas non plus d'option de débogage.

Quelqu'un peut-il nous aider à comprendre quel est le problème ?

Était-ce utile?

La solution

Très étrange mais j'ai exporté le module puis je l'ai importé et il fonctionne bien maintenant.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top