下面的条件,怎么样加到SQL里面,
目的,根据查询条件(动态的条件),生成一个查询表
Dim fit As String
With e.Form.Controls("开始日期DateTimePicker1")
If .value IsNot Nothing Then
fit = "[移动日期] >= '" & .value & "'"
End If
End With
With e.Form.Controls("结束日期DateTimePicker2")
If .value IsNot Nothing Then
If fit > "" Then
fit = fit & " and "
End If
fit = fit & "[移动日期] <= '" & .value & "'"
End If
End With
With e.Form.Controls("人员ComboBox1")
If .value IsNot Nothing Then
If fit > "" Then
fit = fit & " and "
End If
fit = fit & "[用户名] = '" & .value & "'"
End If
End With
With e.Form.Controls("移动类型ComboBox1")
If .value IsNot Nothing Then
If fit > "" Then
fit = fit & " and "
End If
fit = fit & "[移动类型] = '" & .value & "'"
End If
End With
If fit > "" Then
MessageBox.show(fit)
Dim jb As new SQLJoinTableBuilder("记录导出","库存")
jb.C
jb.AddCols("物料编码","物料描述","结存","移动日期","移动单元","移动类型","用户名")
jb.Filter = " Select 物料编码,物料描述,结存,移动日期,移动单元,移动类型,用户名 FR OM {库存} WHRER " & fit & " "
jb.Build
End If