无法为此对象赋值(Access VBA)我。物体

问题描述 投票:0回答:1

因此,我有以下代码,单击按钮即可在 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

sql vba ms-access
1个回答
0
投票

通过将以下内容添加到代码顶部来解决,PN_Changed 是此特定程序运行的表单的名称

Forms("PN_Changed").RecordLocks = 0
© www.soinside.com 2019 - 2024. All rights reserved.