请教老师,我在按钮写入以下代码,如果输入没有数据的年份,点击按钮 报错未引用实例,有数据的年份点击按钮加载正常
各表在currentchanged中有代码
Dim sd As WinForm.ComboBox
sd = e.Form.Controls("ComboBox3")
If sd.Value Is Nothing Then
Messagebox.Show("请先输入 年份","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Else
Dim Cb As String = sd.Value
Dim y As Integer = Cb
Dim dt1 As New Date(y, 1, 1)
Dim dt2 As New Date(y, 12, 31)
Dim Filter As String
Filter = "拜访日期 >= '" & dt1 & "' And 拜访日期 <= '" & dt2 & "'"
DataTables("查询_Table1").LoadFilter = Filter '设置加载条件
DataTables("查询_Table1").Load(False) '加载数据
Dim Filter1 As String
Filter1 = "初审日期 >= '" & dt1 & "' And 初审日期 <= '" & dt2 & "'"
DataTables("查询_Table2").LoadFilter = Filter1 '设置加载条件
DataTables("查询_Table2").Load(False) '加载数据
end if