我一直在excel vba中开发一个程序已经有一段时间没有错误了。然而今天,adter只评论了sub之外的东西,我的所有函数现在抛出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()
如上所述,现在这种情况一直没有问题。没有选择进行调试。
任何人都可以协助解决问题吗?
答案 0 :(得分:0)
非常奇怪,但我导出了模块,然后导入了它,现在它正常工作。