?? select.frm
字號:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form sel
BackColor = &H00FFFFFF&
BorderStyle = 0 'None
Caption = "查找"
ClientHeight = 495
ClientLeft = 0
ClientTop = 0
ClientWidth = 4695
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 495
ScaleMode = 0 'User
ScaleWidth = 4650.568
ShowInTaskbar = 0 'False
StartUpPosition = 1 '所有者中心
Begin MSAdodcLib.Adodc Adodc2
Height = 375
Left = 1800
Top = 840
Visible = 0 'False
Width = 1935
_ExtentX = 3413
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
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 = 375
Left = 2040
Top = 840
Visible = 0 'False
Width = 1815
_ExtentX = 3201
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
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 VB.ComboBox Combo1
Height = 300
Left = 120
TabIndex = 0
Text = "查詢類別"
Top = 120
Width = 1215
End
Begin VB.CommandButton Command2
BackColor = &H80000009&
Caption = "取消"
Height = 255
Left = 3960
TabIndex = 3
Top = 120
Width = 615
End
Begin VB.CommandButton Command1
BackColor = &H80000009&
Caption = "確定"
Default = -1 'True
Height = 255
Left = 3240
TabIndex = 2
Top = 120
Width = 615
End
Begin VB.TextBox Text1
Height = 270
Left = 1440
TabIndex = 1
Text = "查詢條件及對象"
Top = 120
Width = 1695
End
Begin VB.Line Line4
BorderColor = &H008080FF&
X1 = 4635.71
X2 = 4635.71
Y1 = 0
Y2 = 480
End
Begin VB.Line Line3
BorderColor = &H008080FF&
X1 = 0
X2 = 0
Y1 = 0
Y2 = 480
End
Begin VB.Line Line2
BorderColor = &H000000FF&
X1 = 0
X2 = 4635.71
Y1 = 0
Y2 = 0
End
Begin VB.Line Line1
BorderColor = &H008080FF&
X1 = 0
X2 = 4635.71
Y1 = 480
Y2 = 480
End
End
Attribute VB_Name = "sel"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
On Error Resume Next
Dim provider As String
Dim datasource As String
provider = "provider=Microsoft.jet.oledb.4.0"
datasource = "data source=" & App.Path & "\DB.mdb"
If Text1.Text = "" Then '查找
MsgBox "請輸入查詢內容!", 48, "提示"
Exit Sub
End If
Dim sql As String
'sql = "select * from users where"
s = Text1.Text
If Combo1.Text = "學號" Then
sql = "select * from users where 學號='" & Trim(s) & "' "
ElseIf Combo1.Text = "班級" Then
sql = "select * from users where 班級='" & Trim(s) & "' "
ElseIf Combo1.Text = "姓名" Then
sql = "select * from users where 姓名='" & Trim(s) & "' "
Else
MsgBox "請輸入查詢類別!", 48, "提示"
Exit Sub
End If
With Adodc2
.Mode = adModeReadWrite
.ConnectionString = provider & ";" & datasource
.CommandType = adCmdText
.RecordSource = sql
.Refresh
End With
Set main.DataGrid1.datasource = Adodc2
main.DataGrid1.Refresh
Set users.datasource = Nothing
Set users.datasource = sel.Adodc2
Call main.dx
Unload Me
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim provider As String
Dim datasource As String
provider = "provider=Microsoft.jet.oledb.4.0"
datasource = "data source=" & App.Path & "\DB.mdb"
With Adodc1
.Mode = adModeReadWrite
.ConnectionString = provider & ";" & datasource
.CommandType = adCmdTable
.RecordSource = "users"
.Refresh
End With
Combo1.AddItem "學號"
Combo1.AddItem "班級"
Combo1.AddItem "姓名"
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -