我试图在VB中声明DAO变量,但是当我转到赋值语句时,它说必须声明它们。但我刚刚在上面宣布了它们!发生了什么事?
代码:
Public Class frmBaseForm Public acDb As dao.Database Public acRs As dao.Recordset acRs = acDb.OpenRecordset("Something") End Class
acRs在最后一行显示为未声明。
答案 0 :(得分:2)
Public Class frmBaseForm
Public acDb As dao.Database
Public acRs As dao.Recordset
Public Sub ArbitraryEvent()
acDB = New dao.Database
acRs = acDb.OpenRecordset("Something")
End Sub
End Class
或类似的东西
答案 1 :(得分:0)
您必须首先在项目中添加Dao对象库(以防您还没有这样做)。