使用 Access 的数据库 Design/Open 表单 VBA 中的 CLICK EVENT:特定查询
Database Design/Open Form CLICK EVENT in VBA using Access: Specific Inquiry
我希望在 "Main Information" 表单中编写一个点击事件,该表单将根据在多答案查找字段组合控件中选择的值(对应于数字 ID field/text 字符串类别通过独立的、单独的 table) 包含在 "Main Information" 表格中。
我了解到这是通用代码:
Private Sub DiagCat_AfterUpdate()
Select Case DiagCat
Case "Cancer [140-208]"
DoCmd.OpenForm (Cancer_Form)
Case "Heart Disease [393-398, 402, 410-429]"
DoCmd.OpenForm (Heart_Disease_Form)
Case "Stroke [430-438]"
DoCmd.OpenForm (Stroke_Form)
Case "Diabetes [250]"
DoCmd.OpenForm (Diabetes_Form)
Case "Hypertension [401]"
DoCmd.OpenForm (Hypertension_Form)
Case "Liver Disease [070, 571-573]"
DoCmd.OpenForm (Elevated_Cholesterol_Form)
End Select
End Sub
VBA 现在发出 "Type Mismatch" 错误 13;错误在 'Case "Cancer [140-208]"' 行执行。
谢谢。非常感谢任何帮助。
Select Case
关键字是 select 基于字段的多个值的操作所需要的。
Private Sub cmdOpen_Click() 'where cmdOpen is the button control clicked to open the forms
Select Case cmbDxCatsID 'assuming cmbDxCatsID is the name of the combobox control on the form
Case 1
DoCmd.OpenForm(Form1)
Case 2
DoCmd.OpenForm(Form2)
'etc.........
End Select
End Sub
我希望在 "Main Information" 表单中编写一个点击事件,该表单将根据在多答案查找字段组合控件中选择的值(对应于数字 ID field/text 字符串类别通过独立的、单独的 table) 包含在 "Main Information" 表格中。
我了解到这是通用代码:
Private Sub DiagCat_AfterUpdate()
Select Case DiagCat
Case "Cancer [140-208]"
DoCmd.OpenForm (Cancer_Form)
Case "Heart Disease [393-398, 402, 410-429]"
DoCmd.OpenForm (Heart_Disease_Form)
Case "Stroke [430-438]"
DoCmd.OpenForm (Stroke_Form)
Case "Diabetes [250]"
DoCmd.OpenForm (Diabetes_Form)
Case "Hypertension [401]"
DoCmd.OpenForm (Hypertension_Form)
Case "Liver Disease [070, 571-573]"
DoCmd.OpenForm (Elevated_Cholesterol_Form)
End Select
End Sub
VBA 现在发出 "Type Mismatch" 错误 13;错误在 'Case "Cancer [140-208]"' 行执行。
谢谢。非常感谢任何帮助。
Select Case
关键字是 select 基于字段的多个值的操作所需要的。
Private Sub cmdOpen_Click() 'where cmdOpen is the button control clicked to open the forms
Select Case cmbDxCatsID 'assuming cmbDxCatsID is the name of the combobox control on the form
Case 1
DoCmd.OpenForm(Form1)
Case 2
DoCmd.OpenForm(Form2)
'etc.........
End Select
End Sub