0

I manage an Access DB (accdb) and it contains some information about my company that I don´t want others to access it out of my company´s server.

I thought to use Environ (5)=computername or Environ (12)=path to retrieve some references such as LEN(environ(path)). With this function, I could, for instance, make sure that the accdb file only works if LEN(environ(path))/2+15=55 (the lenght at my company´s server divided by 2 plus 15 = 80/2+15=55 = algorhytm).

So, on opening the db, it should prompt for a number/code. If the user inserts 55 and the filepath = 80, it will open. If filepath=100 (filepath out of my company´s server), must be prompted 100/2+15=65 to open the db.

Unfortunelly, I don't know how to programe it neither I know how to block the use of SHIFT (that breakes the VBA code on opening) because I'm a rookie.

So, if you please, can you help me to solve these huge problems (1. algorhytm using Environ, 2. avoid using SHIFT on opening).

Thanks in advance.

Bruno

Erik A
  • 31,639
  • 12
  • 42
  • 67
bmrp17
  • 11
  • 1
  • TBH, you're much better off restricting access to it via the file system. I haven't run across ***any*** protection other than an Encrypt with Password that isn't fairly easy to bypass. The other option is to use a DBMS that has finer grained security, such as SQL Server Express. – Comintern Feb 06 '19 at 23:57
  • 1
    As Comintern says, use encryption. You can just disable VBA altogether, and any VBA-based security will fail. Adding code like this gives a false sense of security, which is often worse than no security at all. – Erik A Feb 07 '19 at 08:16

1 Answers1

0

Add this code to your startup form. When the form opens it will check for the username and computername, and if both match the form will open.

Private Sub Form_Open(Cancel As Integer)
    If Not (Environ("username") = "santosh" And Environ("computername") = "ABC-CAP1-093") Then
        Cancel = True
        Application.Quit
    End If
End Sub

Avoid using shift key - I have already answered see this link

Santosh
  • 12,175
  • 4
  • 41
  • 72