我有 2 个表,从它们中我做了一个名为“Query_Dates”的查询。在那里,我创建了 4 个计算字段,用于比较前面提到的两个表的字段。我想做的是每次计算的字段等于“Diff”时,从第二个表(ADHOC)中获取值并将其放入第一个表(Master_Table)中。总共有 4 个字段我会根据其他 4 个字段(CheckRR、CheckQual、CheckProd、CheckCap)进行更改。
问题是它给了我一个错误 3027, object is read-only in line where it is shown "rsd.edit" 。有人可以帮助我或给我任何反馈吗?先感谢您。
下面,您可以找到代码。
enter code here
Private Sub Comando27_Click()
Dim rsd As DAO.Recordset
Dim supplierName As String
Set rsd = Application.CurrentDb.OpenRecordset("Query_Dates", dbOpenDynaset)
retry: supplierName = InputBox("Please enter the Supplier Name", _
"Information Required")
'MsgBox "Supplier requested: " & supplierName
valid = MsgBox("Supplier Requested = " & supplierName & "??", vbYesNoCancel, "Validation")
If valid = 7 Then
GoTo retry
ElseIf valid = 2 Then
GoTo salir
End If
rsd.MoveFirst
Do While Not rsd.EOF
If rsd![Supplier Name] = supplierName Then
If rsd![CheckRR] = "Diff" And rsd![ADHOC_Run at Rate Dt] <> Empty Then
rsd.Edit
rsd![Run at Rate Dt] = rsd![ADHOC_Run at Rate Dt]
rsd.Update
End If
If rsd![CheckQual] = "Diff" And rsd![ADHOC_Qual Verif Dt] <> Empty Then
rsd.Edit
rsd![Master_Table_Qual Verif Dt] = rsd![ADHOC_Qual Verif Dt]
rsd.Update
End If
If rsd![CheckProd] = "Diff" And rsd![ADHOC_Prod Verif Dt] <> Empty Then
rst.Edit
rsd![Master_Table_Prod Verif Dt] = rsd![ADHOC_Prod Verif Dt]
rsd.Update
End If
If rsd![CheckCap] = "Diff" And rsd![ADHOC_Prod Verif Dt] <> Empty Then
rsd.Edit
rsd![Master_Table_Cap Verif Dt] = rsd![ADHOC_Cap Verif Dt]
rsd.Update
End If
End If
rsd.MoveNext
Loop
salir: rsd.Close
Set rsd = Nothing
End Sub