论文首页哲学论文经济论文法学论文教育论文文学论文历史论文理学论文工学论文医学论文管理论文艺术论文 |
如图(2)多项查询模块窗体图
2.3.3编写程序代码:
上述设计完成后,可以对窗体及控件的事件编写代码:
下面程序可实现“物资名称”为某值,供货日期在一定范围的采购明细的查询。
‘定义变量
Dim my_db As Database Dim my_dr As Recordset Dim com_txt As String Dim txt1 As Date Dim txt2 As Date Private Sub Command1_Click()
‘判断如果输入值不是日期型的,是无效值 If Not IsDate(Text1.Text) Then z = MsgBox("非法起始日期,请重新输入!", vbCritical, "严重警告,输入无效!")
Text1.SetFocus
Else
If Not IsDate(Text2.Text) Then
z = MsgBox("非法终止日期,请重新输入!", vbCritical, "严重警告,输入无效!")
Text2.SetFocus
Else
If Val(DateDiff("d", (Text1.Text), (Text2.Text))) >= 0 Then
'''*****设置条件*********
com_txt = Form5.Combo1.Text
txt1 = Form5.Text1.Text
txt2 = Form5.Text2.Text
Set my_db = OpenDatabase("d:\zu_vb\in_db.mdb")
Set my_dr = my_db.OpenRecordset("input") (转载自http://zw.NSEAC.com科教作文网)
ww1 = "select * from input where (物资名称=" & "'" & com_txt & "'" _
… & " and (供货日期 between " & "#" & txt1 & "#" _
& " and " & "#" & txt2 & "#))"
Data1.RecordSource = ww1
Data1.Refresh
Else