vb 急急。求大虾帮忙解决下
来源:百度知道 编辑:UC知道 时间:2024/05/18 17:56:44
Private Sub Command1_Click()
Dim find_date1 As String
Dim find_date2 As String
If Option1.Value = True Then
Data1.RecordSource = "select * from 图书登记 where 编号 between '" & Combo1.Text & "' " & " and " & " '" & Combo2.Text & "'"
End If
If Option2.Value = True Then
find_date1 = Format(CDate(Combo3.Text & "-" & Combo4.Text & "-" & Combo5.Text), "yyyy-mm-dd")
find_date2 = Format(CDate(Combo6.Text & "-" & Combo7.Text & "-" & Combo8.Text), "yyyy-mm-dd")
Data1.RecordSource = "select * from 图书登记 where 购买日期 between #" & find_date1 & "#" & " and" & " #" & find_date2 & "#"
Data1.Refresh
End If
End Sub
这样单击控件后没报错,也没输出,小弟刚学vb,希望大虾帮个忙
ZHRX 说的是那样的啊,
Dim find_date1 As String
Dim find_date2 As String
If Option1.Value = True Then
Data1.RecordSource = "select * from 图书登记 where 编号 between '" & Combo1.Text & "' " & " and " & " '" & Combo2.Text & "'"
End If
If Option2.Value = True Then
find_date1 = Format(CDate(Combo3.Text & "-" & Combo4.Text & "-" & Combo5.Text), "yyyy-mm-dd")
find_date2 = Format(CDate(Combo6.Text & "-" & Combo7.Text & "-" & Combo8.Text), "yyyy-mm-dd")
Data1.RecordSource = "select * from 图书登记 where 购买日期 between #" & find_date1 & "#" & " and" & " #" & find_date2 & "#"
Data1.Refresh
End If
End Sub
这样单击控件后没报错,也没输出,小弟刚学vb,希望大虾帮个忙
ZHRX 说的是那样的啊,
Data1.RecordSource = "select * from 图书登记 where 编号 between '" & Combo1.Text & "' " & " and " & " '" & Combo2.Text & "'"
不理解,估计是SQL语句问题:
假如Combo1.Text=1,Combo1.Text=2,那么你的语句就是
Data1.RecordSource = "select * from 图书登记 where 编号 between '1' and '2'"
真的不理解
加上:
debug.print "select * from 图书登记 where 编号 between '" & Combo1.Text & "' " & " and " & " '" & Combo2.Text & "'"
把打印出来的sql语句到查询分析器中运行 一下 看看有没有查到信息