[英]Error in MS Access: Run-time Error '424': Object Required
我當前正在制作一個按鈕,該按鈕應該使用子窗體(鏈接到另一個表)中的數據更新表。 應該只獲取那些由用戶選中了復選框(fldFlag)的記錄的數據。
這是我遇到問題的代碼
If tblCoverageBatch.fldFlag = True Then
如果有幫助,請在下面找到整個代碼
Private Sub CmdAssignSTOT_Click()
'Declarations
Dim ask As String
Dim x As Integer
Dim DB As DAO.Database
Dim rst As DAO.Recordset
'popup message box to confirm save
ask = MsgBox("Do you want to save new STOT entry?", vbQuestion + vbYesNo, "System message...") = vbYes
If ask = True Then
'initialize value of incrementing variable x
x = 0
Set DB = CurrentDb
Set rst = DB.OpenRecordset("STOTCoverageBatchAssigned") 'setting the table
Do While x < DCount("[ID]", "[STOTCoverageBatchUnassigned]") 'actions below to be performed until the last record
If tblCoverageBatch.fldFlag = True Then 'actions below will only be performed when their tickbox fldFlag is ticked.
With rst 'encoding!
.Edit
![STOTNo] = Me.STOTNo
![STOTDate] = Me.STOTDate
![BatchNo] = STOTCoverageBatchUnassigned.BatchNo
![PCICCheck] = STOTCoverageBatchUnassigned.CompleteDocsPCIC
![ARBCheck] = STOTCoverageBatchUnassigned.CompleteDocsARB
![PCICDocsReceivedDate] = STOTCoverageBatchUnassigned.PCICDocsReceivedDate
![ARBDocsReceivedDate] = STOTCoverageBatchUnassigned.ARBDocsReceivedDate
.Update
End With
x = x + 1 'increment x by 1 to move on to the next record
End If
Loop
Me.STOTNo.Value = Nz(DLast("STOTNo", "tblSTOT"), 0) + 1 'increment STOT number in the STOTNo field only when actions above have been performed
End If
End Sub`
謝謝!
嘗試這個:
Private Sub CmdAssignSTOT_Click()
'Declarations
Dim ask As Boolean
Dim x As Integer
Dim DB As DAO.Database
Dim rst As DAO.Recordset
'popup message box to confirm save
ask = MsgBox("Do you want to save new STOT entry?", vbQuestion + vbYesNo, "System message...") = vbYes
If ask = True Then
'initialize value of incrementing variable x
Set DB = CurrentDb
Set rst = DB.OpenRecordset("STOTCoverageBatchAssigned") 'setting the table
While Not rst.EOF
If rst.fldFlag.Value = True Then 'actions below will only be performed when their tickbox fldFlag is ticked.
With rst 'encoding!
.Edit
![STOTNo] = Me.STOTNo
![STOTDate] = Me.STOTDate
![BatchNo] = Me!STOTCoverageBatchUnassigned.BatchNo
![PCICCheck] = Me!STOTCoverageBatchUnassigned.CompleteDocsPCIC
![ARBCheck] = Me!STOTCoverageBatchUnassigned.CompleteDocsARB
![PCICDocsReceivedDate] = Me!STOTCoverageBatchUnassigned.PCICDocsReceivedDate
![ARBDocsReceivedDate] = Me!STOTCoverageBatchUnassigned.ARBDocsReceivedDate
.Update
.MoveNext
End With
Me!STOTNo.Value = Nz(DMax("STOTNo", "tblSTOT"), 0) + 1 'increment STOT number in the STOTNo field only when actions above have been performed
End If
Wend
rst.Close
End If
但是,它將僅在子窗體中使用當前記錄,我不知道您是否想要什么,因為尚不清楚您要完成什么。 結束子
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.