Office中国论坛/Access中国论坛

标题: 关于 循环自动备份 [打印本页]

作者: asdfasdfok    时间: 2005-7-3 19:01
标题: 关于 循环自动备份
Function BakPath(str As String)

On Error GoTo Exit_Err

  Dim rs As Recordset

  Dim strSQL As String

  Dim lng As Long

  

  BakPath = False

  strSQL = "select * from bak order by bak.id;"

  Set rs = CurrentDb.OpenRecordset(strSQL)

  If rs.RecordCount >= 10 Then

    rs.MoveFirst

    lng = rs("id")

    Kill rs("bakpath")

    DoCmd.SetWarnings False

    DoCmd.RunSQL "delete * from bak where bak.id=" & lng & ";"

    DoCmd.SetWarnings True

   

    rs.addNew

    rs("bakpath") = str

    rs.Update

  Else

    rs.addNew

    rs("bakpath") = str

    rs.Update

  End If

  rs.Close

  Set rs = Nothing

  

  BakPath = True

  Exit Function

Exit_Err:

  MsgBox Err.Description

  Exit Function

End Function

每次备份时将备份文件名添加到 表"BAK"中的"BakPath"字段中,如果BAK中的记录大于等于10

则移动到首记录,删除首记录中"BakPath"里的文件.并删除首记录,然后添加....更新记录

现在不知道哪里错了,无法实现,请指教
作者: asdfasdfok    时间: 2005-7-3 19:46
解决了,原来不能用RecordCount 做判断还是要老老实实用DCOUNT
作者: LucasLynn    时间: 2005-7-5 08:44
以下是引用asdfasdfok在2005-7-3 11:46:00的发言:

解决了,原来不能用RecordCount 做判断还是要老老实实用DCOUNT



设定一下rs打开的方式就可以用RecordCount了。




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3