标题:急救~!!各位高手帮帮我吧,谢谢 谢谢~!!
只看楼主
bai1111
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2004-12-6
 问题点数:0 回复次数:1 
急救~!!各位高手帮帮我吧,谢谢 谢谢~!!

这个是单表的查询窗体 语句在下面 里面有错误 Public s As String Dim a2 As String, a3 As String, a4 As String

Private Sub com1_Click() If text1.Value = "" Or cb2.Value = "" Or cb3.Value = "" Or text2.Value = "" Then MsgBox ("输入的全部值不可为空!") Else text2.SetFocus s = s + " AND " text2.Text = s com1.Enabled = False com2.Enabled = False com3.Enabled = True End If End Sub

Private Sub com2_Click() If text1.Value = "" Or cb2.Value = "" Or cb3.Value = "" Or text2.Value = "" Then MsgBox ("输入的全部值不可为空!") Else text2.SetFocus s = s + " OR " text2.Text = s com1.Enabled = False com2.Enabled = False com3.Enabled = True End If

End Sub

Private Sub com3_Click() cb2.SetFocus a2 = cb2.Text cb3.SetFocus a3 = cb3.Text text1.SetFocus a4 = text1.Text If a4 = "" Or a2 = "" Or a3 = "" Then MsgBox ("输入的全部值不可为空!") Else If cb2.Value = "采购员编号" Then 's = s + " " + a2 + " " + a3 + " " + "'" + "*" + a4 + "*" + "'" s = s + a2 + a3 + a4 ElseIf cb3 = "LIKE" Or cb3 = "NOT LIKE" Then s = s + " " + a2 + " " + a3 + " " + "'" + "*" + a4 + "*" + "'"

Else s = s + " " + a2 + " " + a3 + " " + "'" + a4 + "'" End If

text2.SetFocus text2.Text = s com1.Enabled = True com2.Enabled = True com3.Enabled = True End If

End Sub

Private Sub com4_Click() l1.RowSource = "SELECT * FROM 采购员资料表 WHERE " + s + ";"

If text2.Value = "" Then MsgBox ("请先按ADD键") End If

End Sub

Private Sub com5_Click()

s = "" text2.Value = "" text1.Value = "" cb2.Value = "" cb3.Value = "" l1.Value = "" l1.RowSource = "" com1.Enabled = False com2.Enabled = False

End Sub

Private Sub Form_Load() com1.Enabled = False com2.Enabled = False com3.Enabled = True

End Sub

Private Sub l1_BeforeUpdate(Cancel As Integer)

End Sub

Private Sub 主体_Click()

End Sub

Private Sub 关闭窗体_Click() On Error GoTo Err_关闭窗体_Click

DoCmd.Close

Exit_关闭窗体_Click: Exit Sub

Err_关闭窗体_Click: MsgBox Err.Description Resume Exit_关闭窗体_Click End Sub

这个是多表的查询窗体图 多表的语句现在就查一个判断字段类型的函数了

Public s As String Dim a2 As String, a3 As String, a4 As String

Private Sub com1_Click() If text1.Value = "" Or cb2.Value = "" Or cb3.Value = "" Or text2.Value = "" Then MsgBox ("输入的全部值不可为空!") Else text2.SetFocus s = s + " AND " text2.Text = s com1.Enabled = False com2.Enabled = False com3.Enabled = True End If End Sub

Private Sub com2_Click() If text1.Value = "" Or cb2.Value = "" Or cb3.Value = "" Or text2.Value = "" Then MsgBox ("输入的全部值不可为空!") Else text2.SetFocus s = s + " OR " text2.Text = s com1.Enabled = False com2.Enabled = False com3.Enabled = True End If

End Sub

Private Sub com3_Click() cb2.SetFocus a2 = cb2.Text cb3.SetFocus a3 = cb3.Text text1.SetFocus a4 = text1.Text If a4 = "" Or a2 = "" Or a3 = "" Then MsgBox ("输入的全部值不可为空!") Else If cb2.Value = "采购员编号" Or cb2.Value = "仓库编号" Or cb2.Value = "库存量" Then 's = s + " " + a2 + " " + a3 + " " + "'" + "*" + a4 + "*" + "'" s = s + a2 + a3 + a4 ElseIf cb3 = "LIKE" Or cb3 = "NOT LIKE" Then s = s + " " + a2 + " " + a3 + " " + "'" + "*" + a4 + "*" + "'"

Else s = s + " " + a2 + " " + a3 + " " + "'" + a4 + "'" End If

text2.SetFocus text2.Text = s com1.Enabled = True com2.Enabled = True com3.Enabled = True End If

End Sub

Private Sub com4_Click() l1.RowSource = "SELECT * FROM 查询1 WHERE " + s + ";"

If text2.Value = "" Then MsgBox ("请先按ADD键") End If

End Sub

Private Sub com5_Click()

s = "" text2.Value = "" text1.Value = "" cb2.Value = "" cb3.Value = "" l1.Value = "" l1.RowSource = "" com1.Enabled = False com2.Enabled = False

End Sub

Private Sub Form_Load() com1.Enabled = False com2.Enabled = False com3.Enabled = True

End Sub

Private Sub l1_BeforeUpdate(Cancel As Integer)

End Sub

Private Sub 主体_Click()

End Sub

Private Sub 关闭窗体_Click() On Error GoTo Err_关闭窗体_Click

DoCmd.Close

Exit_关闭窗体_Click: Exit Sub

Err_关闭窗体_Click: MsgBox Err.Description Resume Exit_关闭窗体_Click End Sub

搜索更多相关主题的帖子: String Sub 急救 
2005-01-17 00:28
mengye
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2005-2-9
得分:0 
太笼统了,你自已慢慢调试吧! VB就是这么学会的! 若可以,请将工程文件压缩发给我吧!改改再给你! mengye_lb@163.com
2005-03-02 06:21



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-11403-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.109919 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved