📄 form31.frm
字号:
BackColor = &H00E0E0E0&
Caption = "查找内容"
ForeColor = &H00000000&
Height = 255
Left = 4680
TabIndex = 18
Top = 1440
Width = 735
End
Begin VB.Label Label8
BackColor = &H00E0E0E0&
Caption = "逻辑关系"
ForeColor = &H00000000&
Height = 255
Left = 6960
TabIndex = 17
Top = 1440
Width = 1095
End
Begin VB.Label Label9
BackColor = &H00E0E0E0&
Caption = "字段名"
ForeColor = &H00000000&
Height = 255
Left = 840
TabIndex = 16
Top = 2640
Width = 615
End
Begin VB.Label Label10
BackColor = &H00E0E0E0&
Caption = "关系"
ForeColor = &H00000000&
Height = 255
Left = 2520
TabIndex = 15
Top = 2640
Width = 615
End
Begin VB.Label Label11
BackColor = &H00E0E0E0&
Caption = "查找内容"
ForeColor = &H00000000&
Height = 255
Left = 4680
TabIndex = 14
Top = 2640
Width = 735
End
Begin VB.Label Label12
BackColor = &H00E0E0E0&
Caption = "逻辑关系"
ForeColor = &H00000000&
Height = 255
Left = 6960
TabIndex = 13
Top = 2640
Width = 975
End
End
End
Attribute VB_Name = "frmqfc"
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 = 5 And Not Combo1.ListIndex = 6 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 = 5 And Not Combo4.ListIndex = 6 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 = 5 And Not Combo7.ListIndex = 6 And Not Combo8.ListIndex = 0 Then
MsgBox "该字段的查找关系不能为 > 或 < !", vbOKOnly + vbInformation, "注意"
Combo8.SetFocus
Exit Sub
End If
'设置查询判断变量为真
queryhouse = True
'使用全局变量sqlqh保存该查询表达式的sql 语句
'如果查询字段是使用面积和单价总价,则需要转换text1.text的内容
If Combo1.ListIndex = 3 Or Combo1.ListIndex = 5 Or Combo1.ListIndex = 6 Then
'Val 函数把字符串转换为数字
sqlqh = "where " & Combo1.Text & Combo2.Text & Val(Text1.Text)
Else
sqlqh = "where " & Combo1.Text & Combo2.Text & "'" & Text1.Text & "'"
End If
If Not Text2.Text = "" Then
If Combo4.ListIndex = 3 Or Combo1.ListIndex = 5 Or Combo1.ListIndex = 6 Then
'combo3.text是and or not 等逻辑字符,其前后需要各加上一个空格
sqlqh = sqlqh & " " & Combo3.Text & " " & Combo4.Text & Combo5.Text & Val(Text2.Text)
Else
sqlqh = sqlqh & " " & Combo3.Text & " " & Combo4.Text & Combo5.Text & "'" & Text2.Text & "'"
End If
End If
If Not Text3.Text = "" Then
If Combo7.ListIndex = 3 Or Combo1.ListIndex = 5 Or Combo1.ListIndex = 6 Then
sqlqh = sqlqh & " " & Combo6.Text & " " & Combo7.Text & Combo8.Text & Val(Text3.Text)
Else
sqlqh = sqlqh & " " & Combo6.Text & " " & Combo7.Text & Combo8.Text & "'" & Text3.Text & "'"
End If
End If
frmB2.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 = 5 And Not Combo1.ListIndex = 6 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 = 5 And Not Combo4.ListIndex = 6 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 = 5 And Not Combo7.ListIndex = 6 And Not Combo8.ListIndex = 0 Then
MsgBox "该字段的查找关系不能为 > 或 < !", vbOKOnly + vbInformation, "注意"
Combo8.SetFocus
Exit Sub
End If
'设置查询判断变量为真
queryhouse = True
'使用全局变量sqlqh保存该查询表达式的sql 语句
'如果查询字段是使用面积和单价总价,则需要转换text1.text的内容
If Combo1.ListIndex = 3 Or Combo1.ListIndex = 5 Or Combo1.ListIndex = 6 Then
'Val 函数把字符串转换为数字
sqlqh = "where " & Combo1.Text & Combo2.Text & Val(Text1.Text)
Else
sqlqh = "where " & Combo1.Text & Combo2.Text & "'" & Text1.Text & "'"
End If
If Not Text2.Text = "" Then
If Combo4.ListIndex = 3 Or Combo1.ListIndex = 5 Or Combo1.ListIndex = 6 Then
'combo3.text是and or not 等逻辑字符,其前后需要各加上一个空格
sqlqh = sqlqh & " " & Combo3.Text & " " & Combo4.Text & Combo5.Text & Val(Text2.Text)
Else
sqlqh = sqlqh & " " & Combo3.Text & " " & Combo4.Text & Combo5.Text & "'" & Text2.Text & "'"
End If
End If
If Not Text3.Text = "" Then
If Combo7.ListIndex = 3 Or Combo1.ListIndex = 5 Or Combo1.ListIndex = 6 Then
sqlqh = sqlqh & " " & Combo6.Text & " " & Combo7.Text & Combo8.Text & Val(Text3.Text)
Else
sqlqh = sqlqh & " " & Combo6.Text & " " & Combo7.Text & Combo8.Text & "'" & Text3.Text & "'"
End If
End If
frmtableFc.Show
Unload Me
End Sub
Private Sub Form_Load()
'让窗体居中
frmqfc.Width = 9255
frmqfc.Height = 5895
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 + -