0
Dim rst1 As DAO.Recordset
Dim rst2 As DAO.Recordset
Set rst1 = CurrentDb.OpenRecordset("Table1", 2)
Set rst2 = CurrentDb.OpenRecordset("Table2", 2)
Dim strName As String
If Not (rst1.EOF And rst1.BOF) Then
rst1.MoveFirst
Do Until rst1.EOF
rst1.Edit
strName = rst1![Name]
rst2.FindFirst ("[Name] = '" & strName & "'")
If rst2.NoMatch Then
If rst1![Accepted] Is Not Null Then 'here is the line causing error
... 'more code going on
因此,上面是我的代碼的摘錄。我儘可能簡化了它,而不改變上下文。情況如下:VBA中的運行時錯誤424訪問
我有兩個表,並希望檢查表1中的人是否已經存在於表2中。如果是這種情況,那就忽略它。如果不是,那麼我想檢查Table1中的另一個條件(如果DateTime
字段[Accepted]不是NULL
),並且如果它滿足繼續處理該人員的數據。
然而,即使我能夠得到妥善rst1![Name]
,當我進入內if
我得到424運行時錯誤:所需的對象。
任何想法如何克服這一點?
工程就像一個魅力,非常感謝! – pkrysiak 2014-11-25 11:51:17
啊,我明白了。謝謝。 – paulroho 2014-11-25 11:55:47