📄 frmqueryclient.frm
字号:
Left = 720
TabIndex = 16
Top = 1320
Width = 855
End
Begin VB.Label Label3
Caption = "逻辑关系"
Height = 255
Left = 6480
TabIndex = 15
Top = 360
Width = 735
End
Begin VB.Label Label2
Caption = "查找值"
Height = 255
Left = 4560
TabIndex = 14
Top = 360
Width = 615
End
Begin VB.Label Label1
Caption = "查找字段"
Height = 255
Left = 720
TabIndex = 13
Top = 360
Width = 855
End
End
End
Attribute VB_Name = "frmQueryClient"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdQueryOne_Click()
'要求至少要有一个查询条件,而且查询条件要靠前写,即如果只有一个查询条件
'必须输在第一行,有2个查询条件,只能输在1,2两行上
If Text1.Text = "" Then
MsgBox "请输入至少一个查询条件,或把查询条件输入在前面的行上!", vbOKOnly + vbInformation, "注意"
Text1.SetFocus
Text2.Text = ""
Text3.Text = ""
Exit Sub
End If
If Text2.Text = "" And Not Text3.Text = "" Then
MsgBox "请把查询条件输入在前面的行上!", vbOKOnly + vbInformation, "注意"
Text2.SetFocus
Text3.Text = ""
Exit Sub
End If
'除使用面积和入住时间以外的查询字段其查询关系不能为> 或 <,判断之
If Not Text1.Text = "" And Not Combo1.ListIndex = 3 And Not Combo1.ListIndex = 7 And Not Combo2.ListIndex = 0 Then
MsgBox "该字段的查找关系不能为 > 或 < !", vbOKOnly + vbInformation, "注意"
Combo2.SetFocus
Exit Sub
End If
If Not Text2.Text = "" And Not Combo4.ListIndex = 3 And Not Combo4.ListIndex = 7 And Not Combo5.ListIndex = 0 Then
MsgBox "该字段的查找关系不能为 > 或 < !", vbOKOnly + vbInformation, "注意"
Combo5.SetFocus
Exit Sub
End If
If Not Text3.Text = "" And Not Combo7.ListIndex = 3 And Not Combo7.ListIndex = 7 And Not Combo8.ListIndex = 0 Then
MsgBox "该字段的查找关系不能为 > 或 < !", vbOKOnly + vbInformation, "注意"
Combo8.SetFocus
Exit Sub
End If
'设置查询判断变量为真
query = True
'使用全局变量sqlqc保存该查询表达式的sql 语句
'如果查询字段是使用面积和入住时间,则需要转换text1.text的内容
If Combo1.ListIndex = 3 Then
'Val 函数把字符串转换为数字
sqlqc = "where " & Combo1.Text & Combo2.Text & Val(Text1.Text)
ElseIf Combo1.ListIndex = 7 Then
If IsDate(Text1.Text) = False Then
MsgBox "输入的不是日期型内容,请输入这样的日期格式:2003-8-3!", vbOKOnly + vbInformation, "注意"
Exit Sub
End If
'DateValue函数把字符串转换为日期
sqlqc = "where " & Combo1.Text & Combo2.Text & "#" & DateValue(Text1.Text) & "#"
Else
sqlqc = "where " & Combo1.Text & Combo2.Text & "'" & Text1.Text & "'"
End If
If Not Text2.Text = "" Then
If Combo4.ListIndex = 3 Then
'combo3.text是and or not 等逻辑字符,其前后需要各加上一个空格
sqlqc = sqlqc & " " & Combo3.Text & " " & Combo4.Text & Combo5.Text & Val(Text2.Text)
ElseIf Combo4.ListIndex = 7 Then
If IsDate(Text2.Text) = False Then
MsgBox "输入的不是日期型内容,请输入这样的日期格式:2003-8-3!", vbOKOnly + vbInformation, "注意"
Exit Sub
End If
sqlqc = sqlqc & " " & Combo3.Text & " " & Combo4.Text & Combo5.Text & "#" & DateValue(Text2.Text) & "#"
Else
sqlqc = sqlqc & " " & Combo3.Text & " " & Combo4.Text & Combo5.Text & "'" & Text2.Text & "'"
End If
End If
If Not Text3.Text = "" Then
If Combo7.ListIndex = 3 Then
sqlqc = sqlqc & " " & Combo6.Text & " " & Combo7.Text & Combo8.Text & Val(Text3.Text)
ElseIf Combo7.ListIndex = 7 Then
If IsDate(Text3.Text) = False Then
MsgBox "输入的不是日期型内容,请输入这样的日期格式:2003-8-3!", vbOKOnly + vbInformation, "注意"
Exit Sub
End If
sqlqc = sqlqc & " " & Combo6.Text & " " & Combo7.Text & Combo8.Text & "#" & DateValue(Text3.Text) & "#"
Else
sqlqc = sqlqc & " " & Combo6.Text & " " & Combo7.Text & Combo8.Text & "'" & Text3.Text & "'"
End If
End If
frmClient.Show
Unload Me
End Sub
Private Sub cmdQueryTable_Click()
'要求至少要有一个查询条件,而且查询条件要靠前写,即如果只有一个查询条件
'必须输在第一行,有2个查询条件,只能输在1,2两行上
If Text1.Text = "" Then
MsgBox "请输入至少一个查询条件,或把查询条件输入在前面的行上!", vbOKOnly + vbInformation, "注意"
Text1.SetFocus
Text2.Text = ""
Text3.Text = ""
Exit Sub
End If
If Text2.Text = "" And Not Text3.Text = "" Then
MsgBox "请把查询条件输入在前面的行上!", vbOKOnly + vbInformation, "注意"
Text2.SetFocus
Text3.Text = ""
Exit Sub
End If
'除使用面积和入住时间以外的查询字段其查询关系不能为> 或 <,判断之
If Not Text1.Text = "" And Not Combo1.ListIndex = 3 And Not Combo1.ListIndex = 7 And Not Combo2.ListIndex = 0 Then
MsgBox "该字段的查找关系不能为 > 或 < !", vbOKOnly + vbInformation, "注意"
Combo2.SetFocus
Exit Sub
End If
If Not Text2.Text = "" And Not Combo4.ListIndex = 3 And Not Combo4.ListIndex = 7 And Not Combo5.ListIndex = 0 Then
MsgBox "该字段的查找关系不能为 > 或 < !", vbOKOnly + vbInformation, "注意"
Combo5.SetFocus
Exit Sub
End If
If Not Text3.Text = "" And Not Combo7.ListIndex = 3 And Not Combo7.ListIndex = 7 And Not Combo8.ListIndex = 0 Then
MsgBox "该字段的查找关系不能为 > 或 < !", vbOKOnly + vbInformation, "注意"
Combo8.SetFocus
Exit Sub
End If
'设置查询判断变量为真
query = True
'使用全局变量sqlqc保存该查询表达式的sql 语句
'如果查询字段是使用面积和入住时间,则需要转换text1.text的内容
If Combo1.ListIndex = 3 Then
'Val 函数把字符串转换为数字
sqlqc = "where " & Combo1.Text & Combo2.Text & Val(Text1.Text)
ElseIf Combo1.ListIndex = 7 Then
If IsDate(Text1.Text) = False Then
MsgBox "输入的不是日期型内容,请输入这样的日期格式:2003-8-3!", vbOKOnly + vbInformation, "注意"
Exit Sub
End If
'DateValue函数把字符串转换为日期
sqlqc = "where " & Combo1.Text & Combo2.Text & "#" & DateValue(Text1.Text) & "#"
Else
sqlqc = "where " & Combo1.Text & Combo2.Text & "'" & Text1.Text & "'"
End If
If Not Text2.Text = "" Then
If Combo4.ListIndex = 3 Then
'combo3.text是and or not 等逻辑字符,其前后需要各加上一个空格
sqlqc = sqlqc & " " & Combo3.Text & " " & Combo4.Text & Combo5.Text & Val(Text2.Text)
ElseIf Combo4.ListIndex = 7 Then
If IsDate(Text2.Text) = False Then
MsgBox "输入的不是日期型内容,请输入这样的日期格式:2003-8-3!", vbOKOnly + vbInformation, "注意"
Exit Sub
End If
sqlqc = sqlqc & " " & Combo3.Text & " " & Combo4.Text & Combo5.Text & "#" & DateValue(Text2.Text) & "#"
Else
sqlqc = sqlqc & " " & Combo3.Text & " " & Combo4.Text & Combo5.Text & "'" & Text2.Text & "'"
End If
End If
If Not Text3.Text = "" Then
If Combo7.ListIndex = 3 Then
sqlqc = sqlqc & " " & Combo6.Text & " " & Combo7.Text & Combo8.Text & Val(Text3.Text)
ElseIf Combo7.ListIndex = 7 Then
If IsDate(Text3.Text) = False Then
MsgBox "输入的不是日期型内容,请输入这样的日期格式:2003-8-3!", vbOKOnly + vbInformation, "注意"
Exit Sub
End If
sqlqc = sqlqc & " " & Combo6.Text & " " & Combo7.Text & Combo8.Text & "#" & DateValue(Text3.Text) & "#"
Else
sqlqc = sqlqc & " " & Combo6.Text & " " & Combo7.Text & Combo8.Text & "'" & Text3.Text & "'"
End If
End If
frmTableClient.Show
Unload Me
End Sub
Private Sub Form_Load()
'让窗体居中
Dim X0 As Long
Dim Y0 As Long
X0 = Screen.Width
Y0 = Screen.Height
X0 = (X0 - Me.Width) / 2
Y0 = (Y0 - Me.Height) / 2
Me.Move X0, Y0
Combo1.ListIndex = 0
Combo2.ListIndex = 0
Combo3.ListIndex = 0
Combo4.ListIndex = 0
Combo5.ListIndex = 0
Combo6.ListIndex = 0
Combo7.ListIndex = 0
Combo8.ListIndex = 0
Combo9.ListIndex = 0
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -