main_find.frm
上传用户:wd52qq
上传日期:2022-07-24
资源大小:5366k
文件大小:5k
- VERSION 5.00
- Begin VB.Form main_find
- BorderStyle = 3 'Fixed Dialog
- Caption = "普通查询窗口"
- ClientHeight = 2025
- ClientLeft = 45
- ClientTop = 330
- ClientWidth = 6810
- Icon = "main_find.frx":0000
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 2025
- ScaleWidth = 6810
- ShowInTaskbar = 0 'False
- StartUpPosition = 2 '屏幕中心
- Begin VB.Frame Frame1
- Height = 1155
- Left = 75
- TabIndex = 2
- Top = 90
- Width = 6645
- Begin VB.ComboBox cboFields
- BackColor = &H80000018&
- Height = 300
- Left = 945
- Style = 2 'Dropdown List
- TabIndex = 5
- Top = 255
- Width = 2295
- End
- Begin VB.TextBox txtdata
- BackColor = &H80000018&
- Height = 300
- Left = 945
- TabIndex = 4
- Top = 690
- Width = 5490
- End
- Begin VB.ComboBox cboOperator
- BackColor = &H80000018&
- Height = 300
- Left = 4140
- Style = 2 'Dropdown List
- TabIndex = 3
- Top = 225
- Width = 2295
- End
- Begin VB.Label Label3
- Caption = "字段名称 运算符"
- ForeColor = &H00FF0000&
- Height = 285
- Left = 135
- TabIndex = 7
- Top = 315
- Width = 5280
- End
- Begin VB.Label Label4
- Caption = "关 键 字"
- ForeColor = &H00FF0000&
- Height = 255
- Left = 135
- TabIndex = 6
- Top = 720
- Width = 1155
- End
- End
- Begin VB.CommandButton cmdFind
- Caption = "查询"
- Height = 360
- Left = 1740
- TabIndex = 1
- Top = 1410
- Width = 1635
- End
- Begin VB.CommandButton cmdExit
- Caption = "退出"
- Height = 360
- Left = 3450
- TabIndex = 0
- Top = 1410
- Width = 1635
- End
- End
- Attribute VB_Name = "main_find"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Dim fld
- Dim rs As New ADODB.Recordset
- Private Sub Form_Load()
- rs.Open "select * from " & tb, Cnn, adOpenKeyset, adLockOptimistic
- Set fld = rs.Fields
- For Each fld In rs.Fields
- '向combo控件中添加字段
- cboFields.AddItem fld.Name
- Next
- rs.Close
- cboFields.ListIndex = 0
- '向cboOperator中添加查询条件
- cboOperator.AddItem ("like")
- cboOperator.AddItem (">")
- cboOperator.AddItem ("=")
- cboOperator.AddItem (">=")
- cboOperator.AddItem ("<")
- cboOperator.AddItem ("<=")
- cboOperator.AddItem ("<>")
- cboOperator.ListIndex = 0
- End Sub
- Private Sub cmdFind_Click() '查询
- rs.Open "select * from " & tb, Cnn, adOpenKeyset, adLockOptimistic
- Select Case rs.Fields(cboFields.ListIndex).Type
- Case 129, 200, 201 '字符型
- If cboOperator.text = "like" Then
- sql = tb & " where " & tb & "." & cboFields & " like+ '%'+'" + txtdata + "'+'%'"
- Else
- sql = tb & " where " & tb & "." & cboFields & cboOperator & "'" + txtdata + "'"
- End If
- Case 135 '日期数据
- If cboOperator.text = "like" Then
- MsgBox "日期型数据不能选用“Like”作为运算符!", , "提示窗口"
- cboOperator.ListIndex = 1
- End If
- If IsDate(txtdata) = False Then
- MsgBox "请输入正确的日期!", , "提示窗口"
- rs.Close
- Exit Sub
- End If
- sql = tb & " where " & tb & "." & cboFields & cboOperator & "'" + txtdata + "'"
- Case 131, 20, 3, 6 '数值型数据
- If IsNumeric(txtdata) = False Then
- MsgBox "请输入正确的数据!", , "提示窗口"
- rs.Close
- Exit Sub
- End If
- If cboOperator.text = "like" Then
- MsgBox "货币数据不能选用“Like”作为运算符!", , "提示窗口"
- cboOperator.ListIndex = 1
- End If
- sql = tb & " where " & tb & "." & cboFields & cboOperator & txtdata
- End Select
- rs.Close
- Unload Me
- End Sub
- Private Sub cmdExit_Click()
- Unload Me
- End Sub