⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmhistoryquery.frm

📁 本人用VB 6.0和ACCESS编写的水费管理系统
💻 FRM
字号:
VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Object = "{00028C01-0000-0000-0000-000000000046}#1.0#0"; "DBGRID32.OCX"
Begin VB.Form frmHistoryQuery 
   Caption         =   "历史查询"
   ClientHeight    =   6570
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   9750
   Icon            =   "frmHistoryQuery.frx":0000
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   6570
   ScaleWidth      =   9750
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton cmdPrint 
      Caption         =   "打印(&P)"
      Default         =   -1  'True
      Height          =   375
      Left            =   2948
      TabIndex        =   7
      Top             =   6000
      Width           =   1095
   End
   Begin VB.TextBox txtPage 
      Height          =   270
      Left            =   8520
      TabIndex        =   10
      Top             =   6052
      Width           =   375
   End
   Begin MSComCtl2.UpDown UpDown 
      Height          =   270
      Left            =   8896
      TabIndex        =   11
      Top             =   6052
      Width           =   240
      _ExtentX        =   423
      _ExtentY        =   476
      _Version        =   393216
      Value           =   1
      BuddyControl    =   "txtPage"
      BuddyDispid     =   196609
      OrigLeft        =   9240
      OrigTop         =   6000
      OrigRight       =   9480
      OrigBottom      =   6375
      Min             =   1
      SyncBuddy       =   -1  'True
      Wrap            =   -1  'True
      BuddyProperty   =   65547
      Enabled         =   -1  'True
   End
   Begin MSDBGrid.DBGrid DBGrid1 
      Bindings        =   "frmHistoryQuery.frx":0442
      Height          =   4455
      Left            =   255
      OleObjectBlob   =   "frmHistoryQuery.frx":0456
      TabIndex        =   6
      Top             =   720
      Width           =   9255
   End
   Begin VB.Data Data1 
      Connect         =   "Access"
      DatabaseName    =   ""
      DefaultCursorType=   0  '缺省游标
      DefaultType     =   2  '使用 ODBC
      Exclusive       =   0   'False
      Height          =   405
      Left            =   908
      Options         =   0
      ReadOnly        =   0   'False
      RecordsetType   =   1  'Dynaset
      RecordSource    =   ""
      Top             =   5400
      Width           =   7935
   End
   Begin VB.CommandButton cmdExit 
      Cancel          =   -1  'True
      Caption         =   "退出(&X)"
      Height          =   375
      Left            =   5708
      TabIndex        =   8
      Top             =   6000
      Width           =   1095
   End
   Begin VB.ComboBox comStyle 
      Height          =   300
      Left            =   7328
      Style           =   2  'Dropdown List
      TabIndex        =   5
      Top             =   240
      Width           =   1815
   End
   Begin VB.TextBox txtEndDate 
      Height          =   300
      Left            =   4385
      TabIndex        =   3
      Top             =   240
      Width           =   1815
   End
   Begin VB.TextBox txtBeginDate 
      Height          =   300
      Left            =   1442
      TabIndex        =   1
      Top             =   240
      Width           =   1815
   End
   Begin VB.Label lblMsg 
      AutoSize        =   -1  'True
      Height          =   180
      Left            =   120
      TabIndex        =   12
      Top             =   6097
      Width           =   90
   End
   Begin VB.Label Label4 
      AutoSize        =   -1  'True
      Caption         =   "页数:"
      Height          =   180
      Left            =   8040
      TabIndex        =   9
      Top             =   6090
      Width           =   450
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      Caption         =   "选择类型:"
      Height          =   180
      Left            =   6495
      TabIndex        =   4
      Top             =   300
      Width           =   810
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      Caption         =   "终止日期:"
      Height          =   180
      Left            =   3555
      TabIndex        =   2
      Top             =   300
      Width           =   810
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "起始日期:"
      Height          =   180
      Left            =   615
      TabIndex        =   0
      Top             =   300
      Width           =   810
   End
End
Attribute VB_Name = "frmHistoryQuery"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim strAppName As String, strSQL As String
Dim strPageName() As String
Dim intPageDate() As Date
Dim fso As New FileSystemObject

Private Sub cmdExit_Click()
    Unload Me
End Sub

Private Sub cmdPrint_Click()
    Me.PrintForm
    Printer.EndDoc
End Sub

Private Sub comStyle_Click()
    strSQL = "select * from 主库文件 order by " & comStyle.Text
    Data1.RecordSource = strSQL
    Data1.Refresh
End Sub

Private Sub Data1_Reposition()
    Data1.Caption = "记录:" & Data1.Recordset.AbsolutePosition + 1
End Sub

Private Sub Form_Load()
    comStyle.AddItem "发票号"
    comStyle.AddItem "编号"
    comStyle.AddItem "户名"
    strAppName = App.Path & "\Main" & Year(Now) & Month(Now) & ".mdb"
    Data1.DatabaseName = strAppName
    Data1.RecordSource = "主库文件"
    Data1.Refresh
End Sub

Private Sub txtEndDate_LostFocus()
    On Error GoTo ErrorDate         '错误处理
    Dim dtmBeginDate As Date, dtmEndDate As Date, dtmCurrDate As Date
    Dim intMonth As Integer
    Dim intPage As Integer, i As Integer
    '计算月数并赋给数组
    dtmBeginDate = CDate(txtBeginDate): dtmEndDate = CDate(txtEndDate)
    If dtmEndDate < dtmBeginDate Then
        MsgBox "起始日期大于终止日期!", vbExclamation + vbOKOnly, "历史查询"
        txtBeginDate.SetFocus
        SendKeys "{Home}+{End}"
        Exit Sub
    End If
    intMonth = DateDiff("m", dtmBeginDate, dtmEndDate)
    intPage = intMonth + 1
    ReDim strPageName(intPage), intPageDate(intPage)
    dtmCurrDate = dtmBeginDate
    For i = 1 To intPage
        strPageName(i) = App.Path & "\Main" & Year(dtmCurrDate) & Month(dtmCurrDate) & ".mdb"
        intPageDate(i) = dtmCurrDate
        dtmCurrDate = DateAdd("m", 1, dtmCurrDate)
    Next
    '设定UpDown属性
    UpDown.Min = 1
    UpDown.Max = intPage
    UpDown.Value = 1
    Exit Sub
ErrorDate:
    If Err.Number = 13 Then
        MsgBox "日期格式不对!", vbExclamation + vbOKOnly, "历史查询"
    End If
End Sub

Private Sub txtPage_Change()
    On Error GoTo ErrorHandler
    Dim i As Integer
    i = Val(txtPage)
    If fso.FileExists(strPageName(i)) Then
        Data1.DatabaseName = strPageName(i)
        Data1.Refresh
        lblMsg.Caption = Year(intPageDate(i)) & "年" & Month(intPageDate(i)) & "月数据库"
    Else
        lblMsg.Caption = Year(intPageDate(i)) & "年" & Month(intPageDate(i)) & "月数据库不存在!"
    End If
    Exit Sub
ErrorHandler:
    If Err.Number = 9 Then Exit Sub
End Sub

Private Sub UpDown_DownClick()
    UpDown.Increment = 1
End Sub

Private Sub UpDown_UpClick()
    UpDown.Increment = 1
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -