我正在尝试在 Microsoft Access 中生成一个报告,该报告应根据存储在名为 Checkup 的表中名为 Exams 的字段中的内容创建一个列表。
到目前为止,我有一个带有计算字段的报告和一个带有记录源考试的文本框。计算字段使用 Switch 函数生成列表;这是代码:
=Switch([Examenes]="BHC","BHC" & Chr(13) & Chr(10) & "Hto:" & Chr(13) & Chr(10) & "Gb:" & Chr(13) & Chr(10) & "E:" & Chr(13) & Chr(10) & "S:" & Chr(13) & Chr(10) & "L:" & Chr(13) & Chr(10) & "M:" & Chr(13) & Chr(10) & "St:" & Chr(13) & Chr(10) & "B:",[Examenes]="BHC, VDRL","BHC" & Chr(13) & Chr(10) & "Hto:" & Chr(13) & Chr(10) & "Gb:" & Chr(13) & Chr(10) & "E:" & Chr(13) & Chr(10) & "S:" & Chr(13) & Chr(10) & "L:" & Chr(13) & Chr(10) & "M:" & Chr(13) & Chr(10) & "St:" & Chr(13) & Chr(10) & "B:" & Chr(13) & Chr(10) & "VDRL:",[Examenes]="BHC, EGO, VDRL","BHC" & Chr(13) & Chr(10) & "Hto:" & Chr(13) & Chr(10) & "GB:" & Chr(13) & Chr(10) & "E:" & Chr(13) & Chr(10) & "S:" & Chr(13) & Chr(10) & "L:" & Chr(13) & Chr(10) & "M:" & Chr(13) & Chr(10) & "St:" & Chr(13) & Chr(10) & "B:" & Chr(13) & Chr(10) & "VDRL:" & Chr(13) & Chr(10) & "EGO" & Chr(13) & Chr(10) & "Color:" & Chr(13) & Chr(10) & "Densidad:" & Chr(13) & Chr(10) & "Ph:" & Chr(13) & Chr(10) & "SO:" & Chr(13) & Chr(10) & "Proteinas:" & Chr(13) & Chr(10) & "CE:" & Chr(13) & Chr(10) & "LL:" & Chr(13) & Chr(10) & "FM:" & Chr(13) & Chr(10) & "Nitrito:" & Chr(13) & Chr(10) & "Cristales:",[Examenes]="BHC, EGH, EGO, VDRL","BHC" & Chr(13) & Chr(10) & "Hto:" & Chr(13) & Chr(10) & "Gb:" & Chr(13) & Chr(10) & "E:" & Chr(13) & Chr(10) & "S:" & Chr(13) & Chr(10) & "L:" & Chr(13) & Chr(10) & "M:" & Chr(13) & Chr(10) & "St:" & Chr(13) & Chr(10) & "B:" & Chr(13) & Chr(10) & "VDRL:" & Chr(13) & Chr(10) & "EGO" & Chr(13) & Chr(10) & "Color:" & Chr(13) & Chr(10) & "Densidad:" & Chr(13) & Chr(10) & "Ph:" & Chr(13) & Chr(10) & "SO:" & Chr(13) & Chr(10) & "Proteinas:" & Chr(13) & Chr(10) & "CE:" & Chr(13) & Chr(10) & "LL:" & Chr(13) & Chr(10) & "FM:" & Chr(13) & Chr(10) & "Nitrito:" & Chr(13) & Chr(10) & "Cristales:" & Chr(13) & Chr(10) & "EGH" & Chr(13) & Chr(10) & "Protozoarios:" & Chr(13) & Chr(10) & "Metazoarios:")
代码运行良好,但是,我需要向 Switch 函数添加更多值,但我收到错误消息“文本太长,无法编辑”。由于这个字段是计算出来的,我不能只是去表格并添加更多字符或使其成为备忘录类型字段(或者我至少我不知道如何)。
这个问题有解决方法吗?我还尝试将代码放在报告中的 onLoad(或 OnOpen)事件中,但没有让它工作。访问给我编译错误:预期:列表分隔符或)
这是代码:
Private Sub Report_Open(Cancel As Integer)
Switch([Examenes]="BHC","BHC" & Chr(13) & Chr(10) & "Hto:" & Chr(13) & Chr(10) & "Gb:" & Chr(13) & Chr(10) & "E:" & Chr(13) & Chr(10) & "S:" & Chr(13) & Chr(10) & "L:" & Chr(13) & Chr(10) & "M:" & Chr(13) & Chr(10) & "St:" & Chr(13) & Chr(10) & "B:",[Examenes]="BHC, VDRL","BHC" & Chr(13) & Chr(10) & "Hto:" & Chr(13) & Chr(10) & "Gb:" & Chr(13) & Chr(10) & "E:" & Chr(13) & Chr(10) & "S:" & Chr(13) & Chr(10) & "L:" & Chr(13) & Chr(10) & "M:" & Chr(13) & Chr(10) & "St:" & Chr(13) & Chr(10) & "B:" & Chr(13) & Chr(10) & "VDRL:",[Examenes]="BHC, EGO, VDRL","BHC" & Chr(13) & Chr(10) & "Hto:" & Chr(13) & Chr(10) & "GB:" & Chr(13) & Chr(10) & "E:" & Chr(13) & Chr(10) & "S:" & Chr(13) & Chr(10) & "L:" & Chr(13) & Chr(10) & "M:" & Chr(13) & Chr(10) & "St:" & Chr(13) & Chr(10) & "B:" & Chr(13) & Chr(10) & "VDRL:" & Chr(13) & Chr(10) & "EGO" & Chr(13) & Chr(10) & "Color:" & Chr(13) & Chr(10) & "Densidad:" & Chr(13) & Chr(10) & "Ph:" & Chr(13) & Chr(10) & "SO:" & Chr(13) & Chr(10) & "Proteinas:" & Chr(13) & Chr(10) & "CE
:" & Chr(13) & Chr(10) & "LL:" & Chr(13) & Chr(10) & "FM:" & Chr(13) & Chr(10) & "Nitrito:" & Chr(13) & Chr(10) & "Cristales:",[Examenes]="BHC, EGH, EGO, VDRL","BHC" & Chr(13) & Chr(10) & "Hto:" & Chr(13) & Chr(10) & "Gb:" & Chr(13) & Chr(10) & "E:" & Chr(13) & Chr(10) & "S:" & Chr(13) & Chr(10) & "L:" & Chr(13) & Chr(10) & "M:" & Chr(13) & Chr(10) & "St:" & Chr(13) & Chr(10) & "B:" & Chr(13) & Chr(10) & "VDRL:" & Chr(13) & Chr(10) & "EGO" & Chr(13) & Chr(10) & "Color:" & Chr(13) & Chr(10) & "Densidad:" & Chr(13) & Chr(10) & "Ph:" & Chr(13) & Chr(10) & "SO:" & Chr(13) & Chr(10) & "Proteinas:" & Chr(13) & Chr(10) & "CE:" & Chr(13) & Chr(10) & "LL:" & Chr(13) & Chr(10) & "FM:" & Chr(13) & Chr(10) & "Nitrito:" & Chr(13) & Chr(10) & "Cristales:" & Chr(13) & Chr(10) & "EGH" & Chr(13) & Chr(10) & "Protozoarios:" & Chr(13) & Chr(10) & "Metazoarios:")
End Sub
任何帮助是极大的赞赏!