【问题标题】:Syntax error 3075 in calling from another procedure从另一个过程调用时出现语法错误 3075
【发布时间】:2017-01-18 22:50:02
【问题描述】:

我正在尝试通过调用以下代码的“搜索”按钮在拆分表单上过滤两个日期之间的记录

Sub search()

Dim strCriteria ,taSk As String 

Me.Refresh
If IsNull(Me.txtDiaryDatefrom) Or IsNull(Me.txtDiaryDateTo) 
Then
    MsgBox "Please Enter Date Range", vbInformation, "Date Range Required"
    Me.txtDiaryDatefrom.SetFocus 
Else
    strCriteria = "([DiaryDate]>= # " & Me.txtDiaryDatefrom & " # And [DiaryDate] <= #" & Me.txtDiaryDateTo & " # )"
    taSk = "SELECT * from tblDiary where ( " & strCriteria & ")"
    DoCmd.ApplyFilter , taSk 
End If 

End Sub

在执行时它会给出运行时错误 3075 读数

查询表达式中的语法错误'Select * from tblDiary .....

谁能弄清楚需要什么来修复它??

【问题讨论】:

    标签: vba ms-access-2007


    【解决方案1】:

    您需要删除哈希之间的空格。

    "([DiaryDate]&gt;= #" &amp; Me.txtDiaryDatefrom &amp; "# And [DiaryDate] &lt;= #" &amp; Me.txtDiaryDateTo &amp; "# )"

    我会更改查询,以便结束 [DiaryDate] &lt; Date + 1。这将确保具有日期/时间值的记录不会被意外过滤掉。

    "([DiaryDate]&gt;= #" &amp; DateValue(Me.txtDiaryDatefrom) &amp; "# And [DiaryDate] &lt; #" &amp; DateValue(Me.txtDiaryDateTo) + 1 &amp; "# )"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多