I am (a complete beginner with VB) trying to schedule a shared DB to compact at a chosen time. I have followed the MS knowledge base instructions for Access 2000. The Timer event tries to run but I get an error message, here is the code and error:
Private Sub Form_Timer()
Dim StartTime As String
' Set this variable for the time you want compacting to begin.
StartTime = "19:15 PM"
' If StartTime is now, open the DBNames table and start compacting
If Format(Now(), "medium time") = Format(StartTime, "medium time") Then
Dim RS As DAO.Recordset, DB As DAO.Database
Dim NewDBName As String, DBName As String
Set DB = CurrentDb()
Set RS = DB.OpenRecordset("DBNames")
On Error Resume Next
RS.MoveFirst
Do Until RS.EOF
DBName = RS("DBFolder") & "\" & RS("DBName")
' Create a new name for the compacted database.
' This example uses the old name plus the current date.
NewDBName = Left(DBName, Len(DBName) - 4)
NewDBName = NewDBName & " " & Format(Date, "MMDDYY") & ".mdb"
DBEngine.CompactDatabase DBName, NewDBName
RS.MoveNext
Loop
' Close the form, and then close Microsoft Access
DoCmd.Close acForm, "CompactDB", acSaveYes
RS.Close
DoCmd.Quit acSaveYes
End If
End Sub
ERROR MESSAGE ( with above BOLD code highlighted)
Compile error
User defned type not defined.
Would greatly appreciate any help with this.
Thanks
Russ
Private Sub Form_Timer()
Dim StartTime As String
' Set this variable for the time you want compacting to begin.
StartTime = "19:15 PM"
' If StartTime is now, open the DBNames table and start compacting
If Format(Now(), "medium time") = Format(StartTime, "medium time") Then
Dim RS As DAO.Recordset, DB As DAO.Database
Dim NewDBName As String, DBName As String
Set DB = CurrentDb()
Set RS = DB.OpenRecordset("DBNames")
On Error Resume Next
RS.MoveFirst
Do Until RS.EOF
DBName = RS("DBFolder") & "\" & RS("DBName")
' Create a new name for the compacted database.
' This example uses the old name plus the current date.
NewDBName = Left(DBName, Len(DBName) - 4)
NewDBName = NewDBName & " " & Format(Date, "MMDDYY") & ".mdb"
DBEngine.CompactDatabase DBName, NewDBName
RS.MoveNext
Loop
' Close the form, and then close Microsoft Access
DoCmd.Close acForm, "CompactDB", acSaveYes
RS.Close
DoCmd.Quit acSaveYes
End If
End Sub
ERROR MESSAGE ( with above BOLD code highlighted)
Compile error
User defned type not defined.
Would greatly appreciate any help with this.
Thanks
Russ