因此,我有以下代码,单击按钮即可在 VBA 应用程序中正常运行,但是当我在更改某些字段的值后重新运行它时。代码在 Me.PCN 上停止并出现以下错误。
有没有办法动态重新分配这些值?
Me.PCN = Me.txt_PCN.Value
Me.OldPN = Me.txt_oldPN.Value
Me.Qty_Change = Me.TXT_QTY.Value
Me.NewPart = Me.txt_PN_TO.Value
DoCmd.RunCommand acCmdSaveRecord
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryAdd_PNChange to tblTransaction", acViewNormal, acEdit
DoCmd.OpenQuery "qryUpdatePNChange to tblWhse_Inventory", acViewNormal, acEdit
DoCmd.OpenQuery "qryDelect Record from tblPNChange", acViewNormal, acEdit
DoCmd.SetWarnings True
MsgBox "Transfer Completed"
Exit_error_save_click:
Exit Sub
Error_Save_Click:
MsgBox Err.Description
Resume Exit_error_save_click
尝试删除对象,但遇到另一个错误
DoCmd.DeleteObject
通过将以下内容添加到代码顶部来解决,PN_Changed 是此特定程序运行的表单的名称
Forms("PN_Changed").RecordLocks = 0