NigelRocks
asked on
Object Not Valid
Experts,
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?
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..."
frmMessage.Show
Dim SrcFile As String, DestFile As String
If Not gdbKnowledgeTracker Is Nothing Then
gdbKnowledgeTracker.Close
End If
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")
Unload frmMessage
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
When you set the object reassign blnFlag = True