This was a question I received on one of my YouTube videos.
“That’s good. But how to protect this access database to be limited to certain number of PCs. Because if you copy this database to your friend and give him the password he can give it to another person and so on. What I would like to know is How to protect Access database and limit to certain computers
My response is to:
Check the computername on login and only allow computers that are in your table into your database.
Save your database as an accde
Here’s the plan:
“frmCheck” will load when the database loads, and will check the computer trying to access the database.
When “frmCheck” loads we will use the “Environ” function to check the current computer name:
Only the computer names listed in “tblComputerAllowed” are allowed to access the database.
This code will check against the list of computers and kick out anyone who is not allowed:
Private Sub Form_Load() Dim strComputerName As String strComputerName = Environ("ComputerName") If Not IsNull(DLookup("[c_ComputerName]", "tblComputerAllowed", "[c_ComputerName]='" & strComputerName & "'")) Then MsgBox "Welcome. You may enter." Else MsgBox "You are not authorized to be here and the database will shutdown." Application.Quit End If End Sub
Here is the table the code checks:
If your computer name is “All03dComP” then you are allowed to open the database, otherwise you are kicked out.
(If you accidentally make yourself “not allowed”, bypass the open form by holding the “Shift” key down while you open the database.)
Let me know if you have any questions.
Watch how it’s done:
restrict user logon to specific computer