In the attached subroutine, I'm checking to see if my main database object is Nothing so that it doesn't test for whether or not it's closed. However, I get an error sometimes when I run the program because it says the object is "not valid" or "no longer set". Isn't that what I'm testing for to begin with? If the object is "not valid", how is it getting to the "Close" statement?
Public Sub BackUpDatabase()
frmMessage.lblMessage.Caption = "Backing up database..."
Dim SrcFile As String, DestFile As String
If Not gdbKnowledgeTracker Is Nothing Then
SrcFile = App.Path & "\Data\KnowledgeTracker.mdb"
DestFile = App.Path & "\Data\KnowledgeTracker_BAK.mdb"
Call FileCopy(SrcFile, DestFile)
Set gdbKnowledgeTracker = OpenDatabase(App.Path + "\Data\KnowledgeTracker.mdb")