Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to hide objects in mde format

Status
Not open for further replies.

jcoira

Programmer
Sep 26, 2001
51
0
0
US
Hi,

I understand that if you create a .mde file you are not able to see (or at least modify) objects inside the .mde file. That is exactly what I want to achieve, but when I create a .mde file out of my MS Access 2002 .mdb file, I still have access to all objects in the .mde file. I can even modify them.

Isn't it supposed to be the other way around? Please let me know how to secure my DB by using .mde files.

Thanks,
jc
 
Creating an mde file prevents all design actions in forms, reports amd modules - anything which can have VBA code.
It has no effect in tables and queries since there is no code associated with these objects. If you want to secure these you need to look at Startup options and maybe Access Security which is not a trivial topic. Do not practice on a live database or your only developement copy.
 
Hi JC:

Here is what you need to do.

Step I:
Create a backup copy just in case things do not work out.

Step II:
Click on Module and copy the following code right under OPTION COMPARE DATABASE

Function SetStartupProperties() As Integer
Const DB_Boolean As Long = 1
ChangeProperty "StartupShowDBWindow", DB_Boolean, False
ChangeProperty "StartupShowStatusBar", DB_Boolean, False
ChangeProperty "AllowBuiltinToolbars", DB_Boolean, False
ChangeProperty "AllowFullMenus", DB_Boolean, False
ChangeProperty "AllowToolbarChanges", DB_Boolean, False
ChangeProperty "AllowShortcutMenus", DB_Boolean, False
ChangeProperty "AllowBreakIntoCode", DB_Boolean, False
ChangeProperty "AllowSpecialKeys", DB_Boolean, False
ChangeProperty "AllowBypassKey", DB_Boolean, False
End Function

Function ChangeProperty(strPropName As String, varPropType As Variant,
varPropValue As Variant) As Integer
Dim dbs As Object, prp As Variant
Const conPropNotFoundError = 3270
Set dbs = CurrentDb
On Error GoTo Change_Err
dbs.Properties(strPropName) = varPropValue
ChangeProperty = True
Exit Function
Change_Err:
If Err = conPropNotFoundError Then ' Property not found.
Set prp = dbs.CreateProperty(strPropName, _
varPropType, varPropValue)
dbs.Properties.Append prp
Resume Next
Else
' Unknown error.
ChangeProperty = False
End If
End Function


Save the module as ModStartUp

Step III:
From Tools > Database Utilities > Make MDE File
(You can use the same file name)
This will restrict users opeining the forms in design mode. Therefore, the users can not see and change your codes.


Step IV:
Close all the files

Step V:
Open the newly created file YourNewDatabase.mde (note the extension)

Step VI:
Open a new Macro
Type in RunCode in the first line under Action

and in the FUNCTION NAME type in
SetStartUpProperties ()

Save the Marco as AutoExec

Step VII:
From Tools > StartUp
Uncheck Display Database Window (so the database window will not be visible to the user)

Step VIII
From Tools > Options > General
Check Compact on Close (so the database compacts and reduce its size before closing).

Step IX:
Open and close the database a couple of times for the codes to work. Once the code starts working all you will see is the switchboard.

Note:
Step III thru Step IX should be done only on the newly created .mde file (Rule of thumb - always create a back up mdb file before creating a mde file because even you are restricted from viewing and changing the codes)

Step II is done so that the user does not open the db by using shift+enter to view the database window.

GOOD LUCK AND HOPE THIS HELPS.


 
Thank you guys. I will try PPJOSEPH suggestiongs right away.

jc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top