Application.UserControl property (1 Viewer)

isladogs

CID Moderator
Staff member
Joined
Jan 14, 2017
Messages
12,335
This thread is designed to show how the UserControl property can be used to restrict how an application can be opened.
Just one line of code is required in the Form_Load event of the startup form or in an autoexec macro.

It has been done partly in response to a recent thread by calvinie: Preventing user from opening accde directly but only via another access database

UserControl is a boolean property - True if opened direct, False if opened via another application using automation
See https://docs.microsoft.com/en-us/office/vba/api/access.application.usercontrol

Attached are two examples each containing a Starter app and a Main app, each with one form:
a) BlockDBOpenDirect (as per the original thread request) - the Main app can be opened via the Starter app but cannot be run directly.
Code:
If Application.UserControl =True Then Application.Quit
b) BlockDBRemoteAccess - the exact opposite - the Main app can be run directly but cannot be opened remotely using automation
Code:
If Application.UserControl =False Then Application.Quit
I hope one or other approach is useful to some of you

NOTE:
I have used method b) in conjunction with other security measures such as disabling the shift bypass to help prevent hacking using automation.

However, no Access database can EVER be made 100% secure
A capable and determined hacker can break any Access database given sufficient time and motivation.

Nevertheless, by erecting various barriers, it is certainly possible to make the process so difficult and time consuming that it isn't normally worth attempting.
 

Attachments

Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom