Application.UserControl property (1 Viewer)

Status
Not open for further replies.

isladogs

MVP / VIP
Local time
Today, 17:11
Joined
Jan 14, 2017
Messages
18,186
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

  • BlockDBOpenDirect.zip
    53.2 KB · Views: 353
  • BlockDBRemoteAccess.zip
    53.8 KB · Views: 357
Last edited:
Status
Not open for further replies.

Users who are viewing this thread

Top Bottom