问题描述
我正在为学校开展一个项目,要求我们使用Access建立电子健康记录。 虽然课程不是编程课程(我的编程经验很少),但教师为我们提供了一个视频演示和演示代码
来使用。 我复制了说明,并修改了代码以符合我的表名和字段。 前五个"如果"陈述按预期工作;然而,"选择"语句返回编译错误: 用户定义的类型
未定义。 突出显示的字段是DIM行: Dim MyDB As DAO.Database,MyRec As DAO.Recordset
I am working on a project for school that requires us to build an electronic health record using Access. While the class is not a programming class (and I have little programming experience), the instructor provides us with a video demo and demo code to use. I have copied the instructions, and modified the code to meet my table names and fields. The first five "If" statements work as expected; however, the "Select" statements return a Compile error: User-defined type not defined. The highlighted field is the DIM line: Dim MyDB As DAO.Database, MyRec As DAO.Recordset
我已经包含了代码的副本下面:
I have included a copy of the code below:
Private Sub CmdAlerCheck_Click()
LabelAlerts.Caption =" ;"
'如果病人是男性且50岁以上,则需要进行PSA检测$ b如果Gender.Value =" 1"和CDate(Date_of_Birth.Value)< CDate(DateAdd(" yyyy"," -50",Date))然后
LabelAlerts.Caption ="患者需要PSA测试。" &安培; vbCrLf
结束如果
'40岁以上女性的乳房X光检查警告
如果Gender.Value =" 2英寸和CDate(Date_of_Birth.Value)< CDate(DateAdd(" yyyy"," -40",Date))然后
LabelAlerts.Caption ="患者需要筛查乳房X线照片。" &安培; vbCrLf
结束如果是b
$ b'如果患者为男性且超过50岁,则需要进行结肠直肠癌检查b $ b如果CDate(Date_of_Birth.Value)< CDate(DateAdd(" yyyy"," -50",Date))然后
LabelAlerts.Caption = LabelAlerts.Caption& "患者需要结肠直肠癌筛查转诊。" &安培; vbCrLf
结束如果
'需要肺炎疫苗的警报
如果CDate(Date_of_Birth.Value)< CDate(DateAdd(" yyyy"," -65",Date))然后
LabelAlerts.Caption = LabelAlerts.Caption& "患者需要接种肺炎疫苗。" &安培; vbCrLf
结束如果
'针对当前吸烟者状态需要戒烟的警告
如果( Smoking_Status.Value)="当前吸烟者"然后
LabelAlerts.Caption = LabelAlerts.Caption& "患者需要戒烟治疗。" &安培; vbCrLf
结束如果
Dim MyDB As DAO.Database,MyRec As DAO.Recordset
;
设置MyDB = CurrentDb
'HTN筛选警报
设置MyRec = MyDB.OpenRecordset("选择*来自Visit_Table WHERE Patient_ID ="& Patient_ID.Value&"和Primary_Diagnosis_Enc = 211 ORDER BY Visit_Date DESC")
如果不是MyRec.EOF则为
如果CDate(MyRec![Visit_Date])< CDate(DateAdd(" yyyy"," -1",Date))然后
LabelAlerts.Caption = LabelAlerts.Caption& "患者应该进行HTN对照筛选。" &安培; vbCrLf
结束如果是
结束如果是
'为阿片类药物患者提供麻醉药物b
设置MyRec = MyDB.OpenRecordset(" Select * From Prescription_Table WHERE Patient_ID =" ;& Patient_ID.Value&" and Drug_Name = 79")
如果不是MyRec.EOF则为
LabelAlerts.Caption = LabelAlerts.Caption& "这名患者需要麻醉剂。" &安培; vbCrLf
结束如果
$ MyRec.Close
MyDB.Close
结束子
私人子表格_当前()
LabelAlerts.Caption =""
$
End Sub
Private Sub CmdAlerCheck_Click()
LabelAlerts.Caption = ""
'Alert for the need for a PSA Test if a patient is male and over 50
If Gender.Value = "1" And CDate(Date_of_Birth.Value) < CDate(DateAdd("yyyy", "-50", Date)) Then
LabelAlerts.Caption = "Patient needs a PSA Test." & vbCrLf
End If
'Alert for mammogram for female over 40
If Gender.Value = "2" And CDate(Date_of_Birth.Value) < CDate(DateAdd("yyyy", "-40", Date)) Then
LabelAlerts.Caption = "Patient needs a screening mammogram." & vbCrLf
End If
'Alert for the need for a colorectal cancer screening if a patient is male and over 50
If CDate(Date_of_Birth.Value) < CDate(DateAdd("yyyy", "-50", Date)) Then
LabelAlerts.Caption = LabelAlerts.Caption & "Patient needs a colorectal cancer screening referral." & vbCrLf
End If
'Alert for need for pneumonia vacc
If CDate(Date_of_Birth.Value) < CDate(DateAdd("yyyy", "-65", Date)) Then
LabelAlerts.Caption = LabelAlerts.Caption & "Patient needs a pneumonia vaccination." & vbCrLf
End If
'Alert for the need for a smoking cessation for current smoker status
If (Smoking_Status.Value) = "Current Smoker" Then
LabelAlerts.Caption = LabelAlerts.Caption & "Patient needs smoking cessation counceling." & vbCrLf
End If
Dim MyDB As DAO.Database, MyRec As DAO.Recordset
Set MyDB = CurrentDb
'Alert for HTN screening
Set MyRec = MyDB.OpenRecordset("Select * From Visit_Table WHERE Patient_ID = " & Patient_ID.Value & " and Primary_Diagnosis_Enc = 211 ORDER BY Visit_Date DESC")
If Not MyRec.EOF Then
If CDate(MyRec![Visit_Date]) < CDate(DateAdd("yyyy", "-1", Date)) Then
LabelAlerts.Caption = LabelAlerts.Caption & "Patient is due for HTN control screening." & vbCrLf
End If
End If
'Narcotics conceling for patients on opiods
Set MyRec = MyDB.OpenRecordset("Select * From Prescription_Table WHERE Patient_ID = " & Patient_ID.Value & " and Drug_Name = 79")
If Not MyRec.EOF Then
LabelAlerts.Caption = LabelAlerts.Caption & "This patient needs narcotics counceling." & vbCrLf
End If
MyRec.Close
MyDB.Close
End Sub
Private Sub Form_Current()
LabelAlerts.Caption = ""
End Sub
推荐答案
这篇关于编译错误:访问2016的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!