0

我希望在“主要信息”表单中编写一个单击事件,该事件将根据在多答案查找字段组合控件中选择的值打开多达 17 个其他表单(对应于通过相关的数字 ID 字段/文本字符串类别一个独立的、单独的表格)位于该“主要信息”表格中。

我了解到这是通用代码:

 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 现在发出“类型不匹配”错误 13;错误在“案例“癌症 [140-208]”行上执行。

谢谢你。非常感谢任何帮助。

4

1 回答 1

0

Select Case关键字是您根据字段的多个值选择操作所需的。

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
于 2015-10-14T07:05:34.800 回答