disable an mde file to save any changes to db?

darksniper

Registered User.
Local time
Today, 14:42
Joined
Sep 4, 2005
Messages
108
when I create an mde file, is there a way to disable it to save any changes to db.

For example when users opened an mde file, he can do what ever he needs to do, but when he closes the mde all of the changes done to the database are reverted back to zero.
 
What kind of changes? Do you mean data, table structure, queries, what?
 
mde file prevent any changes to forms,queries, reports or vb code. (in terms of design) .

so I would like to erase all of the data in tables upon the closure of mde file.
 
You could set up several delete queries and have a hidden form that opens when the database opens and then in the hidden form's Unload event you could fire off the queries to delete all of the data.
 
hmm, I could try that. For now I just have to make the project working. Most likely when I will get to that and get stuck I will see what can be done then.

Thx.
 
Simple Software Solutions

The first thing you need to do is to detect if the project the user has open is an MDE or not. To do this you need the following code

Code:
Function IsCompiledFile() As Boolean
    Dim strMDEADE As String
    On Error Resume Next
    If CurrentProject.ProjectType = acMDB Then
        strMDEADE = CurrentDb.Properties("MDE").Value
    Else  'type acADP
        strMDEADE = CurrentProject.Properties("MDE").Value
    End If
    IsCompiledFile = (Err.Number = 0 And strMDEADE = "T")
End Function

Once you have established this then you can do one of two things

If you perform this on application open you can relink to a dummy back end that only contains sample data. Then on the exit of the app it relinks to the live data.

Or

On the exit of the app it deletes contents etc as earlier suggested.

If the user who is opening the app is opening the mdb (you as the developer) it will bypass the functionality.

Sample method used on the Exit application button

Code:
If IsCompiledFile 
   DoCmd.Quit
Else
   DoCmd.Close
End If

CodeMaster::cool:
 

Users who are viewing this thread

Back
Top Bottom