回复 2楼 风吹过b
麻烦大神再给看一下,指导一下,谢谢!
Private Sub Command2_Click()
Dim rec As ADODB.Recordset
Set rec = New ADODB.Recordset
Dim strSQL As String
If Trim(Text1.Text) = "" And Trim(Text2.Text) = "" And Trim(Text3.Text) = "" Then
MsgBox "请输入查询条件", , "提示"
ElseIf Trim(Text1.Text) <> "" And Trim(Text2.Text) = "" And Trim(Text3.Text) = "" Then
strSQL = "select * from biao where xinmin = '" & Text1.Text & "'"
rec.Open strSQL, cn, adOpenStatic, adLockOptimistic
Set DataGrid1.DataSource = rec
ElseIf Trim(Text1.Text) <> "" And Trim(Text2.Text) <> "" And Trim(Text3.Text) = "" Then
strSQL = "select * from biao
where xinmin = '" & Text1.Text & "'and riqi>='" & Text2.Text & "'"
rec.Open strSQL, cn, adOpenStatic, adLockOptimistic
Set DataGrid1.DataSource = rec
ElseIf Trim(Text1.Text) <> "" And Trim(Text2.Text) <> "" And Trim(Text3.Text) <> "" Then
strSQL = "select * from biao where xinmin = '" & Text1.Text & "'and (riqi>='" & Text2.Text & "' and
riqi<='" & Text3.Text & "')"
rec.Open strSQL, cn, adOpenStatic, adLockOptimistic
Set DataGrid1.DataSource = rec
Else
MsgBox "请输入查询条件", , "提示"
End If
Text2.Text = ""
Text3.Text = ""
End Sub
Private Sub Command3_Click()
Dim res As ADODB.Recordset
Set res = New ADODB.Recordset
这里用你说的这一句,报属性无效的错,麻烦大神看一下,怎么写,而且我前面DataGrid1.DataSource的查询比较复杂,如何在这里找到DataGrid1.DataSource中的
1、riqi=text2.text的结果;
2、由riqi=text2.text向前N天的结果(riqi不一定是连续的)。
Set DataGrid2.DataSource = res
End Sub
[此贴子已经被作者于2021-8-1 22:35编辑过]