老师,有以下查询窗口,查询按钮代码如下,执行查询出现以下错误,日期我加了#号,怎么也不对呢?麻烦老师帮忙看一下,谢谢!
此主题相关图片如下:2.png
此主题相关图片如下:1.png
Dim Filter As String
Dim tbl As DataTable = DataTables("订单")
For Each ctl As WinForm.Control In e.Form.Controls '遍历所有控件
If TypeOf ctl Is WinForm.RadioButton Then '如果此控件是RadionButton(单选框)
Dim rdo As WinForm.RadioButton = ctl
If rdo.Checked Then '如果已经选中
rdo.Select '将焦点移到控件上
Exit For
End If
End If
Next
Dim date1 As Date
Dim date2 As Date
With e.Form.Controls("DateTimePicker1")
If .Value IsNot Nothing Then
date1 = .value
Filter = "销单_销单日期 >= #" & CDate(.Value) & "#"
End If
End With
With e.Form.Controls("DateTimePicker2")
If .Value IsNot Nothing Then
date2 = .value
If date2 < date1 Then
MessageBox.Show("【日期起】不能大于【日期至】,请检查!", "提示")
Return
End If
If date2 > date1.AddYears(1) Then
MessageBox.Show("日期间隔不能大于一年,请检查!", "提示")
Return
End If
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "销单_销单日期 < = #" & CDate(.Value) & "#"
End If
End With
With e.Form.Controls("NumericComboBox1")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "分析_超期 > " & .Value
End If
End With
With e.Form.Controls("NumericComboBox2")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "分析_账龄 > " & .Value
End If
End With
With e.Form.Controls("DropBox1")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "客户编号 = '" & .Value & "'"
End If
End With
If e.Form.Controls("RadioButton1").Checked = True Then' 如果选择未结单
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "(结单 = False or 结单 Is Null)"
End If
If e.Form.Controls("RadioButton2").Checked = True Then' 如果选择已结单
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "结单 = True "
End If
If e.Form.Controls("RadioButton3").Checked = True Then' 如果选择全部
Filter = Filter
End If
If Filter > "" Then
Dim Sum As Integer = DataTables("订单").sqlCompute("Count(订单编号)", Filter )
If Sum > 0 Then
Dim Result As DialogResult
Result = MessageBox.Show("后台查询需要加载【" & sum & "】条数据,估计有点慢,是否继续?", "提示",
MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
tbl.loadFilter = Filter
tbl.load()
If Forms("订单主窗口").Opened Then
Forms("订单主窗口").Controls("Label7").text = "数据状态:筛选"
End If
Else
tbl.loadFilter = "[_Identify] Is Null"
tbl.load()
End If
End If
End If