Access交流中心

北京 | 上海 | 天津 | 重庆 | 广州 | 深圳 | 珠海 | 汕头 | 佛山 | 中山 | 东莞 | 南京 | 苏州 | 无锡 | 常州 | 南通 | 扬州 | 徐州 | 杭州 | 温州 | 宁波 | 台州 | 福州 | 厦门 | 泉州 | 龙岩 | 合肥 | 芜湖 | 成都 | 遂宁 | 长沙 | 株洲 | 湘潭 | 武汉 | 南昌 | 济南 | 青岛 | 烟台 | 潍坊 | 淄博 | 济宁 | 太原 | 郑州 | 石家庄 | 保定 | 唐山 | 西安 | 大连 | 沈阳 | 长春 | 昆明 | 兰州 | 哈尔滨 | 佳木斯 | 南宁 | 桂林 | 海口 | 贵阳 | 西宁 | 乌鲁木齐 | 包头 |

ACCESS有没有像EXCEL中VBA的定时备份功能

花落,相依  发表于:2010-06-15 20:16:13  
复制

ACCESS 好像没有EXCEL VBA的这个定时执行功能,请高手指点

Application.OnTime TimeValue("17:00:00"), "my_Procedure"

 

Top
wyh99999 发表于:2010-06-15 21:49:56

可在贵坛中探索“定时”

http://www.accessoft.com/bbs/index.asp



wyh99999 发表于:2010-06-15 21:49:59

可在贵坛中探索“定时”

http://www.accessoft.com/bbs/index.asp



82077802 发表于:2010-06-16 05:39:06
Option Explicit
Private m_strHour As String, m_strMinuter As String, m_alreadyBak As Boolean
Private Sub Form_Load()
    Dim strSourceFile, strDescriptionFile As String
    Dim i As Long
    For i = 0 To 23
        cboHour.AddItem i
    Next i
    For i = 0 To 59
        cboMinute.AddItem i
    Next i
    cboHour.ListIndex = 0
    cboMinute.ListIndex = 0
    txtSource.Text = ""
    txtDescription.Text = ""
    m_strHour = GetSetting("BakDataBase", "Time", "Hour")
    If Len(m_strHour) = 0 Then Exit Sub
    m_strMinuter = GetSetting("BakDataBase", "Time", "Minute")
    strSourceFile = GetSetting("BakDataBase", "File", "SourcePath")
    strDescriptionFile = GetSetting("BakDataBase", "File", "DestinationPath")
    cboHour.Text = m_strHour
    cboMinute.Text = m_strMinuter
    txtSource.Text = strSourceFile
    txtDescription.Text = strDescriptionFile
    Timer1.Enabled = True
    Timer1.Interval = 1000
    Me.Caption = "开始定时备份!"
End Sub
Private Sub cmdDestination_Click()
    Dim lngPos As Long, strFilePath As String, strDlgSelectFile As String
    With DlgSelectFile
        .Filter = "数据文件|*.mdb"
        .FileName = GetFileName(txtSource.Text)
        .ShowSave
    End With
    strDlgSelectFile = DlgSelectFile.FileName
    If Len(strDlgSelectFile) > 0 Then
        lngPos = InStrRev(strDlgSelectFile, "\")
        If lngPos > 0 Then
            strFilePath = Date & " " & cboHour & "点" & cboMinute & "分备份" & _
                          Right$(strDlgSelectFile, Len(strDlgSelectFile) - lngPos)
            txtDescription.Text = Left$(strDlgSelectFile, lngPos) & strFilePath
        End If
    End If
End Sub

Public Function GetFileName(FilePath$) As String
    Dim pos&
    pos& = InStrRev(FilePath$, "\")
    If pos& > 0 Then
        GetFileName = Right$(FilePath, Len(FilePath) - pos&)
    End If
End Function
Private Sub Timer1_Timer()
    If Len(m_strHour) = 0 Then
        Timer1.Enabled = False
        Call Form_Load
    End If
    If Hour(Now) = Int(m_strHour) And Minute(Now) = Int(m_strMinuter) Then
        If m_alreadyBak = False Then
            FileCopy txtSource, txtDescription
            m_alreadyBak = True
        Else
            Timer1.Enabled = False
            m_alreadyBak = False
            Me.Caption = "定时备份数据库"
        End If
    End If
End Sub
Private Sub cmdSource_Click()
    With DlgSelectFile
        .Filter = "数据库文件|*.mdb"
        .ShowOpen
        If Len(.FileName) = 0 Then Exit Sub
        txtSource = .FileName
    End With
End Sub
Private Sub cmdOk_Click()
    Dim strFilePath As String, strDescription As String
    Dim lngPos As Long
    SaveSetting "BakDataBase", "Time", "Hour", cboHour
    SaveSetting "BakDataBase", "Time", "Minute", cboMinute
    SaveSetting "BakDataBase", "File", "SourcePath", txtSource
    SaveSetting "BakDataBase", "File", "DestinationPath", txtDescription
    m_strHour = cboHour
    m_strMinuter = cboMinute
    strDescription = txtDescription.Text
    If Len(strDescription) > 0 Then
        lngPos = InStrRev(strDescription, "份")
        strFilePath = Date & " " & cboHour & "点" & cboMinute & "分备份" & _
                      Right$(strDescription, Len(strDescription) - lngPos)
        lngPos = InStrRev(strDescription, "\")
        txtDescription.Text = Left$(strDescription, lngPos) & strFilePath     '点确定后设置新的定时
    End If
    Me.Caption = "开始定时备份!"
    Timer1.Enabled = True
    Timer1.Interval = 1000
End Sub
Private Sub cmdExit_Click()
    End
End Sub

82077802 发表于:2010-06-16 05:43:19

按日期自动备份当前数据库

 

 

点击下载此附件

liaohk 发表于:2010-06-16 09:34:49

感谢各位,我试试



总记录:5篇  页次:1/1 9 1 :