【问题标题】:Creating a warning in Microsoft Access在 Microsoft Access 中创建警告
【发布时间】:2015-02-13 19:56:56
【问题描述】:

我在 Microsoft Access 中创建了一个患者数据输入表单。它收集的字段之一是病历编号。每位患者只有一个 MR#,无论他们访问办公室多少次。我做了一个单独的查询,查看输入 MR# 的次数 - 例如,患者多久去看一次医生。我想创建一个警报,以便如果 MR# 的出现次数超过 3 次,它会提醒医生。

但是,我无法在网上找到任何信息来帮助我开始编写此警告的代码。 任何提示或编码示例都会非常有帮助。

【问题讨论】:

    标签: database ms-access vba ms-access-2013


    【解决方案1】:

    假设您的病历编号在名为 txtMedicalRecordNumber 的文本框中。

    如果你想让医生输入值并且只显示一个警告,那么将这样的代码放在文本框的 After_Update 事件后面

    If Nz(DCount("MedicalRecordNumber", "MyTable", "MedicalRecordNumber = '" &  me.txtMedicalRecordNumber & "'"), 0) > 3 Then
        MsgBox "This record has been entered more than three times"
    End If
    

    您还可以将 dCount 的结果分配给一个变量,并在消息框中给出条目数。

    如果您想阻止他们进入病历超过 3 次,请使用 Before_Update 事件并取消更新。

    If Nz(DCount("MedicalRecordNumber", "MyTable", "MedicalRecordNumber = '" &  me.txtMedicalRecordNumber & "'"), 0) > 3 Then
        MsgBox "This record has been entered more than three times"
        cancel = true
    End If
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多