Msgbox来自查询访问

时间:2016-12-18 15:04:27

标签: vba access-vba access

我有一个包含Id字段的访问表单。一旦用户输入Id,我想在更新后事件上运行查询以获取患者历史字段并将其显示为msg框。

查询如下:

"Select Patients.[Patient History] From Patients Where Patients.ID = " & Me.PatientID

我该怎么做?

谢谢

1 个答案:

答案 0 :(得分:1)

您可以在单行中使用 DLookup

MsgBox Nz(DLookup("[Patient History]", "Patients", "ID = " & Me!PatientID.Value & "")), vbInformation + vbOkOnly, "Patient History"