PtrSafe 属性错误 MS 访问

Posted

技术标签:

【中文标题】PtrSafe 属性错误 MS 访问【英文标题】:PtrSafe Attribute Error MS Access 【发布时间】:2014-06-05 16:59:17 【问题描述】:

我正在尝试在 MS Access 表单中输入记录,但出现以下编译错误:

“必须更新此项目中的代码才能在 64 位系统上使用。请查看并更新 Declare 语句,然后用 PtrSafe 属性对其进行标记。”

数据库中的代码如下:

Private Sub cboProjectID_Change()
    Dim VarComboKey As Integer

    VarComboKey = Me.cboProjectID.Value

    Me!cboErrCod1.RowSource = "SELECT DISTINCT [Error_Reason_Code], [Reason_Code_Desc] FROM [HDR_ErrCodes] WHERE [project_ID] = " & VarComboKey
    Me!cboErrCod2.RowSource = "SELECT DISTINCT [Error_Reason_Code], [Reason_Code_Desc] FROM [HDR_ErrCodes] WHERE [project_ID] = " & VarComboKey
    Me!cboErrCod3.RowSource = "SELECT DISTINCT [Error_Reason_Code], [Reason_Code_Desc] FROM [HDR_ErrCodes] WHERE [project_ID] = " & VarComboKey
    Me!cboErrCod4.RowSource = "SELECT DISTINCT [Error_Reason_Code], [Reason_Code_Desc] FROM [HDR_ErrCodes] WHERE [project_ID] = " & VarComboKey
    Me!cboErrCod5.RowSource = "SELECT DISTINCT [Error_Reason_Code], [Reason_Code_Desc] FROM [HDR_ErrCodes] WHERE [project_ID] = " & VarComboKey
End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)


   Dim ctl As Control

   On Error GoTo Err_BeforeUpdate


   If Me.Dirty Then

      If MsgBox("Do you want to save?", vbYesNo + vbQuestion, _
              "Save Record") = vbNo Then
         Me.Undo
      End If
   End If

Exit_BeforeUpdate:
   Exit Sub

Err_BeforeUpdate:
   MsgBox Err.Number & " " & Err.Description
   Resume Exit_BeforeUpdate
End Sub

有人可以帮我更新代码以防止出现此错误吗?

【问题讨论】:

这不是所有的代码。你在某处有Declares。 【参考方案1】:

经过一番搜索,我找到了我的声明语句所在的位置。这段代码修复了它:

  #If VBA7 Then
       Private Declare PtrSafe Function GetTickCount Lib "kernel32" () As Long
       #Else
       Private Declare Function GetTickCount Lib "kernel32" () As Long
       #End If

【讨论】:

以上是关于PtrSafe 属性错误 MS 访问的主要内容,如果未能解决你的问题,请参考以下文章

MS Access:数据表属性(作为子表单)- 表单未打开,错误:2489?

MS 访问控制 Property.Type 没有意义

[MS SQL Server]SQL Server如何开启远程访问

MS Edge 支持跨域属性吗?

Confluence 6 属性的一个示例

SQL Server 扩展属性 MS_SubdatasheetName