📄 searchfrm.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form searchfrm
Caption = "记录查询"
ClientHeight = 7200
ClientLeft = 60
ClientTop = 345
ClientWidth = 8880
LinkTopic = "Form1"
MDIChild = -1 'True
ScaleHeight = 7200
ScaleWidth = 8880
Begin VB.CommandButton cmdexit
Caption = "退 出"
Height = 495
Left = 5520
TabIndex = 9
Top = 5520
Width = 1575
End
Begin MSAdodcLib.Adodc Adodata
Height = 375
Left = 1200
Top = 6120
Visible = 0 'False
Width = 2055
_ExtentX = 3625
_ExtentY = 661
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= 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 MSDataGridLib.DataGrid dtgdata
Bindings = "searchfrm.frx":0000
Height = 2655
Left = 720
TabIndex = 8
Top = 2400
Width = 7095
_ExtentX = 12515
_ExtentY = 4683
_Version = 393216
AllowUpdate = -1 'True
HeadLines = 1
RowHeight = 15
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Caption = "数据记录表"
ColumnCount = 2
BeginProperty Column00
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
Begin VB.CommandButton cmdfind
Caption = "查 询"
Height = 495
Left = 1800
TabIndex = 7
Top = 5520
Width = 1575
End
Begin VB.TextBox txtsfname
Height = 375
Left = 2160
TabIndex = 6
Top = 1560
Width = 1815
End
Begin MSComCtl2.DTPicker DTPend
Height = 375
Left = 3840
TabIndex = 4
Top = 720
Width = 1575
_ExtentX = 2778
_ExtentY = 661
_Version = 393216
Format = 24444929
CurrentDate = 37616
End
Begin MSComCtl2.DTPicker DTPstart
Height = 375
Left = 1680
TabIndex = 2
Top = 720
Width = 1575
_ExtentX = 2778
_ExtentY = 661
_Version = 393216
Format = 24444929
CurrentDate = 37616
End
Begin VB.Frame Frame1
Caption = "请输入查询条件"
Height = 1815
Left = 720
TabIndex = 0
Top = 360
Width = 7095
Begin VB.Label Label3
Caption = "收费员姓名"
Height = 375
Left = 360
TabIndex = 5
Top = 1320
Width = 975
End
Begin VB.Label Label2
Caption = "至"
Height = 255
Left = 2760
TabIndex = 3
Top = 480
Width = 615
End
Begin VB.Label Label1
Caption = "日期"
Height = 375
Left = 360
TabIndex = 1
Top = 480
Width = 735
End
End
End
Attribute VB_Name = "searchfrm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rstjinbin As New ADODB.Recordset
Dim cnnjinbin As New ADODB.Connection
Dim strsql As String
Private Sub cmdexit_Click()
searchfrm.Hide
Unload Me
End Sub
Private Sub cmdfind_Click()
Dim startdate As String
Dim enddate As String
'定义收费员姓名变量
Dim sn As String
Dim flag As Boolean
strsql1 = " where "
flag = False
strsql = "select bh AS 编号,hjzs AS 售票总数,hjje AS 合计金额," & _
"station AS 收费站名,riqi AS 日期,bz AS 班组,bc AS 班次,sxm AS 收费员 from data"
'获取查询条件中关于日期时间值的条件
With DTPstart
startdate = CStr(Format(.Value, "yyyy-MM-dd"))
End With
With DTPend
enddate = CStr(Format(.Value, "yyyy-MM-dd"))
End With
'判断是否对日期进行了选择
If Len(Trim(startdate)) <> 0 And Len(Trim(startdate)) <> 0 And ("#" & startdate & "#" <= "#" & enddate & "#") Then
strsql1 = strsql1 & "(riqi between #" & startdate & "# and #" & enddate & "#)"
End If
'判断是否指定了时间值
If Len(Trim(strsql1)) <> 5 Then
strsql = strsql & strsql1
flag = True
End If
'获取收费员的姓名
sn = Trim(txtsfname.Text)
If Len(sn) <> 0 Then
If flag Then
strsql = strsql & " and (sxm='" & sn & "')"
Else
strsql = strsql & "where (sxm='" & sn & "')"
End If
End If
With cnnjinbin
If .State = adStateOpen Then
.Close
End If
.Provider = "microsoft.jet.oledb.4.0"
.ConnectionString = App.Path & "\jinbin.mdb"
.Open
End With
With rstjinbin
If .State = adStateOpen Then
.Close
End If
.LockType = adLockReadOnly
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.ActiveConnection = cnnjinbin
.Open strsql, Options:=adCmdText
End With
'绑定到ADOdata中
With Adodata
Set .Recordset = rstjinbin
End With
'绑定到DTGdata表中
With dtgdata
.ReBind
End With
End Sub
Private Sub Form_Load()
strsql = "select bh AS 编号,hjzs AS 售票总数,hjje AS 合计金额," & _
"station AS 收费站名,riqi AS 日期,bz AS 班组,bc AS 班次,sxm AS 收费员 from data"
With cnnjinbin
If .State = adStateOpen Then
.Close
End If
.Provider = "microsoft.jet.oledb.4.0"
.ConnectionString = App.Path & "\jinbin.mdb"
.Open
End With
With rstjinbin
If .State = adStateOpen Then
.Close
End If
.LockType = adLockReadOnly
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.ActiveConnection = cnnjinbin
.Open strsql, Options:=adCmdText
End With
Set Adodata.Recordset = rstjinbin
dtgdata.ReBind
With searchfrm
.Height = 6900
.ScaleHeight = 7000
End With
With DTPstart
.Format = dtpCustom
.CustomFormat = "yyyy年MM月dd日"
.Value = #12/1/2002#
End With
With DTPend
.Format = dtpCustom
.CustomFormat = "yyyy年MM月dd日"
.Value = Now
End With
With dtgdata
End With
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -