How to Prevent using an Access database on other computers
This Database can run on only 2 Computers.
Purpose
Purpose of this database is
To Prevent Your Database to run on 2nd Computer without your Permission.
This database will not work on 3rd, 4th, 5th ……………. Computer.
After Registration of 1st and 2nd Computer, you can run this database only on these Computers.
Method:
Table: Registration
Main Form
Registration Form
Private Sub btnOK_Click()
If IsNull(txtName) Then
MsgBox (“Please Enter Your Name First !”), vbOKOnly, “Name Required”
DoCmd.GoToControl “txtName”
End
End If
If Not IsNull(txtName) Then
YourName = txtName
GetDate = Date
MB1 = MBSerialNumber()
DoCmd.Close acForm, “Registration”
DoCmd.OpenForm “Registration”
End If
End Sub
Private Sub Form_Load()
If IsNull(YourName) Then
DoCmd.OpenForm “Registration”
End
End If
If Not IsNull(YourName) Then
DoCmd.Close acForm, “Registration”
DoCmd.OpenForm “Login”
End If
End Sub
Login Form
Private Sub btnLogin_Click()
If txtUserName = “Admin” And txtPassword = “123456” Then
DoCmd.OpenForm “Main Form”
DoCmd.Close acForm, “Login”
End
ElseIf txtUserName = “Admin” And txtPassword <> “123456” Then
MsgBox (“You have Typed Wrong Password! Please Try Again”), vbOKOnly, “Wrong Password”
DoCmd.GoToControl “txtPassword”
End
ElseIf txtUserName <> “Admin” And txtPassword = “123456” Then
MsgBox (“You have Typed Wrong UserName! Please Try Again”), vbOKOnly, “Wrong UserName”
DoCmd.GoToControl “txtUserName”
End
ElseIf txtUserName <> “Admin” And txtPassword <> “123456” Then
MsgBox (“You have Typed Wrong Criteria! Please Try Again”), vbOKOnly, “Wrong Input”
txtUserName = “”
txtPassword = “”
End
End If
End Sub
Part 1
Private Sub Form_Load()
GetMB1 = MBSerialNumber()
GetMB2 = MBSerialNumber()
If txtMB1 = GetMB1 Or txtMB2 = GetMB2 Then
End
Else
DoCmd.OpenForm “Illegal Use”
DoCmd.Close acForm, “Login”
End If
End Sub
Illegal Use Form
Private Sub btnYes_Click()
DoCmd.OpenForm “AlFareed”
DoCmd.Close acForm, “Illegal Use”
End Sub
Private Sub btnNo_Click()
DoCmd.Quit
End Sub
AlFareed Form
Private Sub GetMB2_Click()
MB2 = MBSerialNumber()
End Sub
Reset All Form
Private Sub Reset_Click()
GetDate = Null
YourName = Null
MB1 = Null
MB2 = Null
DoCmd.Close acForm, “Reset All”
End Sub
Private Sub Form_Load()
Call Reset_Click
End Sub
Function Code to Get Mother Board Serial Number
Public Function MBSerialNumber() As String
Dim objs As Object
Dim obj As Object
Dim WMI As Object
Dim sAns As String
Set WMI = GetObject(“WinMgmts:”)
Set objs = WMI.InstancesOf(“Win32_BaseBoard”)
For Each obj In objs
sAns = sAns & obj.SerialNumber
If sAns < objs.Count Then sAns = sAns & “2k”
Next
MBSerialNumber = sAns
End Function
References