我对Access VBA还是很陌生,并试图基于两个输入文本框和一个组合框输入打开访问报告。
此表单包含2个基于“索赔过程日期”列的未绑定开始日期和结束日期文本框;并且有一个组合框可以选择客户名称。
我正在尝试创建一个基于这三个条件打开报告的按钮,但是出现不匹配的数据类型错误。
Private Sub Command51_Click()
Dim strCriteria As String
strCriteria = "[Claim Process Date] BETWEEN #" & Me.txtStartDate & "# AND #" & Me.txtEndDate & "#" And "[Customer Name] = '" & Me.Combo49 & "'"
DoCmd.OpenReport "CustomerClaims", acViewPreview, strCriteria
End Sub
任何建议将不胜感激。谢谢
答案 0 :(得分:0)
And
被排除在查询/引号之外,并且缺少空格。
strCriteria = "[Claim Process Date] BETWEEN #" & Me.txtStartDate & "# AND #" & _
Me.txtEndDate & "#" And "[Customer Name] = '" & Me.Combo49 & "'"
成为(参见第二行)
strCriteria = "[Claim Process Date] BETWEEN #" & Me.txtStartDate & "# AND #" & _
Me.txtEndDate & "# And [Customer Name] = '" & Me.Combo49 & "'"