首先,我不确定如何根据用户输入和查询的结果打开报告。所以我决定尝试编写我的代码:
Private Sub menuToReports_Click()
Dim crseFilter As String
'Asks for a course to filter report by
crseFilterQ:
crseFilter = InputBox("Enter a course", "Course Filter")
'If the response is null then returns to asking for filter
If crseFilter = "" Then
MsgBox ("Please enter one of the following: IB, IAL, AS, GCSE or None")
GoTo crseFilterQ
'If reponse is none, then shows all students
ElseIf crseFilter = "None" Then
DoCmd.OpenReport "Students", acViewReport
'Show whatever students are in the course that is specified in the response
Else
DoCmd.OpenReport "Students", acViewReport, , Course = crseFilter
End If
End Sub
每当我运行此代码并给它一个非零响应,例如IB this happens
我已经尝试了几件事情,但似乎无法让它发挥作用,所以我转向堆栈溢出。请帮忙! :P
非常感谢任何帮助 提前致谢
答案 0 :(得分:0)
WHERE CONDITION参数的语法不正确。由于Course是一个文本类型字段:
DoCmd.OpenReport "Students", acViewReport, , "Course = '" & crseFilter & "'"