할당 왼쪽의 함수 호출은 변형 또는 개체 오류를 반환해야 합니다.
-
26-12-2019 - |
문제
나는 한동안 오류없이 Excel VBA에서 프로그램을 개발해 왔습니다.그러나 오늘은 하위 외부 항목만 주석 처리하는 Adter가 이제 내 모든 기능에서 Function call on left-hand side of assignment must return variant or object error
오류.아래 샘플을 참조하세요.
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
오류가 발생합니다.fGetEmployees = oRS.GetRows()
말했듯이 이것은 한동안 문제없이 작동해 왔습니다.디버깅 옵션도 없습니다.
문제가 무엇인지 도와줄 수 있는 사람이 있나요?
해결책
매우 이상하지만 모듈을 내보낸 다음 가져왔고 지금은 잘 작동합니다.
제휴하지 않습니다 StackOverflow