La chiamata di funzione sul lato sinistro dell'assegnazione deve restituire la variante o l'errore dell'oggetto

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

Domanda

Ho sviluppato un programma in Excel VBA da un po 'di tempo senza errori.Oggi tuttavia, aderire solo commentando qualcosa al di fuori di un sub, tutte le mie funzioni ora lanciano un errore Function call on left-hand side of assignment must return variant or object error.Guarda un campione qui sotto:

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'errore viene lanciato sulla linea: fGetEmployees = oRS.GetRows()

Come detto che questo ha funzionato senza problemi per qualche tempo ora.Non c'è nessuna possibilità di debug nemici.

Qualcuno può aiutare con ciò che il problema è?

È stato utile?

Soluzione

Molto strano ma ho esportato il modulo e poi l'ho importato e funziona bene ora.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top