📄 frmfind.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Begin VB.Form 查询
BorderStyle = 4 'Fixed ToolWindow
Caption = "数据查询"
ClientHeight = 4035
ClientLeft = 45
ClientTop = 270
ClientWidth = 6015
LinkTopic = "Form2"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4035
ScaleWidth = 6015
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.ComboBox Combo1
Height = 300
ItemData = "Frmfind.frx":0000
Left = 2400
List = "Frmfind.frx":0019
TabIndex = 1
Text = "="
Top = 480
Width = 975
End
Begin VB.CommandButton Command1
Caption = "将 AND 加入条件"
Height = 375
Left = 240
TabIndex = 3
Top = 1005
Width = 1575
End
Begin VB.CommandButton Command2
Caption = "将 OR 加入条件"
Height = 375
Left = 1920
TabIndex = 4
Top = 1005
Width = 1575
End
Begin VB.CommandButton Command3
Caption = "列出可能的值"
Height = 375
Left = 3840
TabIndex = 5
Top = 1005
Width = 1815
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1335
Left = 240
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 9
Top = 1920
Width = 5535
End
Begin VB.CommandButton Command6
Caption = "取消"
Height = 375
Left = 4320
TabIndex = 8
Top = 3480
Width = 1095
End
Begin VB.CommandButton Command5
Caption = "清除"
Height = 375
Left = 2460
TabIndex = 7
Top = 3480
Width = 1095
End
Begin VB.CommandButton Command4
Caption = "确定"
Height = 375
Left = 600
TabIndex = 6
Top = 3480
Width = 1095
End
Begin MSAdodcLib.Adodc Adodc2
Height = 330
Left = 3240
Top = 1440
Visible = 0 'False
Width = 1200
_ExtentX = 2117
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 2
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 2
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "FILE NAME=C:\Program Files\Common Files\Linkmain .UDL"
OLEDBString = ""
OLEDBFile = "C:\Program Files\Common Files\Linkmain .UDL"
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "main"
Caption = "Adodc2"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin MSAdodcLib.Adodc Adodc1
Height = 330
Left = 1680
Top = 1440
Visible = 0 'False
Width = 1200
_ExtentX = 2117
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 2
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 2
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "FILE NAME=C:\Program Files\Common Files\Linkmain .UDL"
OLEDBString = ""
OLEDBFile = "C:\Program Files\Common Files\Linkmain .UDL"
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "mainformat1"
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin MSDataListLib.DataCombo DataCombo2
Bindings = "Frmfind.frx":003A
Height = 330
Left = 3840
TabIndex = 2
Top = 480
Width = 1815
_ExtentX = 3201
_ExtentY = 582
_Version = 393216
ListField = ""
Text = ""
End
Begin MSDataListLib.DataCombo DataCombo1
Bindings = "Frmfind.frx":004F
Height = 330
Left = 240
TabIndex = 0
Top = 480
Width = 1695
_ExtentX = 2990
_ExtentY = 582
_Version = 393216
ListField = "字段名称"
Text = " "
End
Begin VB.Label Label4
Caption = "全部条件:"
Height = 255
Left = 240
TabIndex = 13
Top = 1560
Width = 855
End
Begin VB.Label Label3
Caption = "值:"
Height = 255
Left = 3840
TabIndex = 12
Top = 120
Width = 735
End
Begin VB.Label Label2
Caption = "运算符:"
Height = 255
Left = 2400
TabIndex = 11
Top = 120
Width = 735
End
Begin VB.Label Label1
Caption = "字段名称:"
Height = 255
Left = 240
TabIndex = 10
Top = 120
Width = 1335
End
End
Attribute VB_Name = "查询"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim r As Integer
Dim a As String
Dim b(2) As String
Dim c As String
Dim n As Integer
Public WithEvents re As Recordset
Attribute re.VB_VarHelpID = -1
Public WithEvents db As Connection
Attribute db.VB_VarHelpID = -1
Private Sub Command1_Click()
Dim type1 As String
b(0) = DataCombo1.Text
b(1) = Combo1.Text
b(2) = DataCombo2.Text
Adodc1.Refresh
Do Until Adodc1.Recordset.EOF
If Adodc1.Recordset.Fields("字段名称") = DataCombo1.Text Then
type1 = Adodc1.Recordset.Fields("类型")
Exit Do
End If
Adodc1.Recordset.MoveNext
Loop
If n = 0 Then
If type1 = "C" Then
a = b(0) & b(1) & "'" & b(2) & "'"
Else
a = b(0) & b(1) & b(2)
End If
c = c & a
Text1.Text = c
n = n + 1
Else
If type1 = "C" Then
a = " and " & b(0) & b(1) & "'" & b(2) & "'"
Else
a = " and " & b(0) & b(1) & b(2)
End If
c = c & a
Text1.Text = c
End If
End Sub
Private Sub Command2_Click()
Dim type1 As String
b(0) = DataCombo1.Text
b(1) = Combo1.Text
b(2) = DataCombo2.Text
Adodc1.Refresh
Do Until Adodc1.Recordset.EOF
If Adodc1.Recordset.Fields("字段名称") = DataCombo1.Text Then
type1 = Adodc1.Recordset.Fields("类型")
Exit Do
End If
Adodc1.Recordset.MoveNext
Loop
If n = 0 Then
If type1 = "C" Then
a = b(0) & b(1) & "'" & b(2) & "'"
Else
a = b(0) & b(1) & b(2)
End If
c = c & a
Text1.Text = c
n = n + 1
Else
If type1 = "C" Then
a = " or " & b(0) & b(1) & "'" & b(2) & "'"
Else
a = " or " & b(0) & b(1) & b(2)
End If
c = c & a
Text1.Text = c
End If
End Sub
Private Sub Command3_Click()
DataCombo2.ListField = DataCombo1.Text
End Sub
Private Sub Command4_Click()
On Error GoTo err
Dim type1 As String
b(0) = DataCombo1.Text
b(1) = Combo1.Text
b(2) = DataCombo2.Text
Adodc1.Refresh
Do Until Adodc1.Recordset.EOF
If Adodc1.Recordset.Fields("字段名称") = DataCombo1.Text Then
type1 = Adodc1.Recordset.Fields("类型")
Exit Do
End If
Adodc1.Recordset.MoveNext
Loop
If n = 0 Then
If type1 = "C" Then
a = b(0) & b(1) & "'" & b(2) & "'"
Else
a = b(0) & b(1) & b(2)
End If
c = c & a
Text1.Text = c
End If
Dim db As Connection
Dim SQL As String
SQL = "select * from main where " & c
c = ""
n = 0
Set db = New Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=Microsoft.Jet.OLEDB.3.51;Data Source=c:\program files\common files\main.mdb;"
Set re = New Recordset
re.Open SQL, db, adOpenStatic, adLockOptimistic
Set Frmmain.DataGrid2.DataSource = re
Unload 查询
For i = 0 To re.Fields.Count - 1
Frmmain.DataGrid2.Columns(i).Width = 10950 / re.Fields.Count
Next i
Frmmain.SSTab1.Tab = 2
Exit Sub
err:
Text1.Text = ""
c = ""
n = 0
MsgBox "条件错误,请重新输入!", vbQuestion + vbOKOnly, "条件错误"
End Sub
Private Sub Command5_Click()
Text1.Text = ""
c = Text1.Text
n = 0
End Sub
Private Sub Command6_Click()
Unload 查询
End Sub
Private Sub Form_Load()
r = 0
Adodc2.Refresh
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -