正如标题所述,当代码试图编译时,我会得到一个错误"Sub或函数未定义“。它会在RS_Logistics上崩溃。该字段确实存在于记录集中,该记录集通过查看表IM_Logistics、检查我在对象上设置的手表和确认字段项“接收”存在而得到验证。这是一个布尔字段。
Option Compare Database
Option Explicit
Private ROID As Long
Private RS As Recordset
Private RS_PartDetail As Recordset
Private RS_Logistics As Recordset
Public Sub Load_ID(RepOrderID As Long)
Dim strSQL As String
strSQL = "SELECT TOP 1 * FROM IM_ReplenishmentOrders WHERE ReplenishmentOrderID = " & RepOrderID
Set RS = CurrentDb.OpenRecordset(strSQL)
If RS.RecordCount > 0 Then
ROID = RepOrderID
strSQL = "SELECT TOP 1 * FROM MT_PartDetail Where MT_PartDetail_ID = " & RS!MT_PartDetail_ID
Set RS_PartDetail = CurrentDb.OpenRecordset(strSQL)
strSQL = "SELECT * FROM IM_Logistics Where ReplenishmentOrderID = " & ROID
Set RS_Logistics = CurrentDb.OpenRecordset(strSQL)
Else
ROID = 0
End If
End Sub
Public Property Get ETA() As Date 'Derived from Logistics Records
On Error GoTo fail
RS_Logistics.MoveFirst
While Not RS_Logistics.EOF
If ((RS_Logistics![Received] = False) And Nz(ETA, DateAdd("Y", 10, today())) > RS_Logistics![Expected Date]) Then
ETA = RS_Logistics![Expected Date]
End If
RS_Logistics.MoveNext
Wend
fail:
End Property我在这个数据库中使用记录集已经有一年多了。不知道为什么现在会出现这种情况。
发布于 2020-07-14 19:03:41
错误消息与记录集或其字段无关。“子函数或未定义函数”是因为今天()不是访问VBA函数。使用日期()
而且,访问VBA DateAdd需要"yyyy“作为年间隔。
发布于 2020-07-15 12:04:22
有2条建议可以更容易地捕捉到这样的东西:
https://stackoverflow.com/questions/62902049
复制相似问题