📄 frminquire.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "Msflxgrd.ocx"
Begin VB.Form frminquire
AutoRedraw = -1 'True
Caption = "查询窗口"
ClientHeight = 5715
ClientLeft = 420
ClientTop = 405
ClientWidth = 5685
FillStyle = 0 'Solid
Icon = "frminquire.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 5715
ScaleWidth = 5685
StartUpPosition = 2 '屏幕中心
Begin VB.Frame Frame2
Caption = "查询结果"
Height = 3135
Left = 120
TabIndex = 11
Top = 2400
Width = 5500
Begin VB.Data Data5
Caption = "Data5"
Connect = "Access"
DatabaseName = "D:\数据库\aaaa.mdb"
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 375
Left = 840
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = ""
Top = 1320
Visible = 0 'False
Width = 3375
End
Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1
Bindings = "frminquire.frx":0E42
Height = 2775
Left = 360
TabIndex = 5
TabStop = 0 'False
Top = 240
Width = 4815
_ExtentX = 8493
_ExtentY = 4895
_Version = 393216
FixedCols = 0
WordWrap = -1 'True
ScrollTrack = -1 'True
AllowUserResizing= 2
End
End
Begin VB.Frame Frame1
Caption = "查询条件"
Height = 2055
Left = 120
TabIndex = 6
Top = 120
Width = 5500
Begin VB.TextBox Text4
Height = 300
Left = 3720
TabIndex = 3
Top = 1130
Width = 1200
End
Begin VB.ComboBox Combo2
Height = 300
ItemData = "frminquire.frx":0E56
Left = 1320
List = "frminquire.frx":0E6F
Style = 2 'Dropdown List
TabIndex = 2
Top = 1130
Width = 1200
End
Begin VB.CommandButton Command1
Caption = "查 询"
Height = 350
Left = 4200
TabIndex = 4
Top = 1560
Width = 700
End
Begin VB.ComboBox Combo1
Height = 300
ItemData = "frminquire.frx":0E9B
Left = 1320
List = "frminquire.frx":0EAE
Style = 2 'Dropdown List
TabIndex = 0
Top = 550
Width = 1200
End
Begin VB.ComboBox Combo3
Height = 300
ItemData = "frminquire.frx":0EDC
Left = 3720
List = "frminquire.frx":0EDE
Style = 2 'Dropdown List
TabIndex = 1
Top = 550
Width = 1200
End
Begin VB.Label Label1
Caption = "3.运算符"
Height = 195
Left = 360
TabIndex = 10
Top = 1200
Width = 735
End
Begin VB.Label Label2
Caption = "4.数值"
Height = 195
Left = 2880
TabIndex = 9
Top = 1200
Width = 735
End
Begin VB.Label Label3
Caption = "2.列名"
Height = 195
Left = 2880
TabIndex = 8
Top = 600
Width = 615
End
Begin VB.Label Label4
Caption = "1.选择表"
Height = 195
Left = 360
TabIndex = 7
Top = 600
Width = 735
End
End
End
Attribute VB_Name = "frminquire"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim a As String
Dim b As String
Dim c As String
Dim d As String
Dim e As String
Dim f As String
Dim i As Integer
Dim j As Integer
Private Sub Combo1_click()
i = Combo1.ListIndex
If i = 0 Then
Combo3.Clear
Combo3.AddItem "学号"
Combo3.AddItem "姓名"
Combo3.AddItem "性别"
Combo3.AddItem "系别"
Combo3.AddItem "课程号"
Combo3.AddItem "课程名"
Combo3.AddItem "成绩"
Combo3.AddItem "教师编号"
Combo3.AddItem "教师姓名"
a = "temp"
ElseIf i = 1 Then
Combo3.Clear
Combo3.AddItem "学号"
Combo3.AddItem "姓名"
Combo3.AddItem "性别"
Combo3.AddItem "系别"
a = "stu"
ElseIf i = 2 Then
Combo3.Clear
Combo3.AddItem "课程号"
Combo3.AddItem "课程名"
Combo3.AddItem "教师编号"
a = "course"
ElseIf i = 3 Then
Combo3.Clear
Combo3.AddItem "学号"
Combo3.AddItem "课程号"
Combo3.AddItem "成绩"
a = "cselect"
ElseIf i = 4 Then
Combo3.Clear
Combo3.AddItem "教师编号"
Combo3.AddItem "教师姓名"
a = "teacher"
End If
End Sub
Private Sub Combo2_click()
c = Combo2.List(Combo2.ListIndex)
End Sub
Private Sub Combo3_click()
If Combo3.Text = "学号" Then
b = "sno"
ElseIf Combo3.Text = "姓名" Then
b = "sname"
ElseIf Combo3.Text = "性别" Then
b = "sex"
ElseIf Combo3.Text = "系别" Then
b = "sdept"
ElseIf Combo3.Text = "课程号" Then
b = "cno"
ElseIf Combo3.Text = "课程名" Then
b = "cname"
ElseIf Combo3.Text = "教师编号" Then
b = "tno"
ElseIf Combo3.Text = "教师名" Then
b = "tname"
ElseIf Combo3.Text = "成绩" Then
b = "grade"
End If
End Sub
Private Sub Command1_Click()
d = Text4.Text
If Combo1.Text = "" Or Combo3.Text = "" Or Combo2.Text = "" Then
j = MsgBox("你没有输入查询条件," + Chr(13) + Chr(10) + "或者查询条件不完整!", vbExclamation + vbOKOnly, "错误提示")
Combo1.SetFocus
Else
e = "select * from " & a & " where " & b & c & " '" & d & "'"
Data5.RecordSource = e
Data5.Refresh
End If
End Sub
Private Sub form_load()
dataname = App.Path & "\aaaa.mdb"
Data5.DatabaseName = dataname
Set db = OpenDatabase(dataname)
On Error Resume Next
sql = "select stu.sno,stu.sname,stu.sex,stu.sdept,course.cname,cselect.grade,teacher.tname into temp from stu,course,cselect,teacher where stu.sno=cselect.sno and cselect.cno=course.cno and course.tno=teacher.tno order by 1"
db.Execute "drop table temp"
db.Execute sql
Data5.RecordSource = "select * from temp"
db.Close
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -