0% found this document useful (0 votes)
6 views

Secure Access With Vba Set Properties Final

Secure access with vba Set properties final

Uploaded by

mrahaqqani
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Secure Access With Vba Set Properties Final

Secure access with vba Set properties final

Uploaded by

mrahaqqani
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Option Compare Database

Option Explicit

'''''''''''''''''''''''''''''''
''''''''insert new module and put the below three codes
1(Setproperties)2(EnableSetProperty)3((DisableSetProperty))'''''''''''''

Public Function SetProperties(strPropName As String, varPropType As Variant,


varPropvalue As Variant) As Integer
On Error GoTo Err_SetProperties
Dim db As Database, prp As Property
'Dim db As DAO. Database, prp AsDAO. Property
Set db = CurrentDb
db.Properties(strPropName) = varPropvalue
SetProperties = True
Set db = Nothing
Exit_SetProperties:
Exit Function
Err_SetProperties:
If Err = 3270 Then 'Proge not found
Set prp = db.CreateProperty(strPropName, varPropType, varPropvalue)
db.Properties.Append prp
Resume Next
Else
SetProperties = False
MsgBox "Runtime Error #" & Err.Number & vbCrLf & vbLf & Err.Description
Resume Exit_SetProperties
End If
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function EnableSetProperty()
On Error GoTo ThisError
DoCmd.ShowToolbar "Ribbon", acToolbarYes
SetProperties "StartUpShowDBWindow", dbBoolean, True 'Display Database window
SetProperties "StartUpShowStatusBar", dbBoolean, True
SetProperties "AllowFullMenus", dbBoolean, True 'Access Full Menus.
SetProperties "AllowSpecialKeys", dbBoolean, True 'F11,ALT F11, etc.
SetProperties "AllowBypassKey", dbBoolean, True ''Shift Key Override on loading
SetProperties "AllowShortcutMenus", dbBoolean, True 'Access ShortcutMenus. May be
too severe.
SetProperties "AllowToolbarChanges", dbBoolean, True 'Prevent Changes.
SetProperties "AllowBreakIntoCode", dbBoolean, True 'Code access.
DoCmd.ShowToolbar "ribbon", acToolbarYes
Call DoCmd.SelectObject(acTable, , True)
ThisError:
MsgBox Err.Description
Exit Function
End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''
Public Function DisableSetProperty()
On Error GoTo ThisError
DoCmd.ShowToolbar "Ribbon", acToolbarNo
SetProperties "StartUpShowDBWindow", dbBoolean, False 'Display Database window
SetProperties "StartUpShowStatusBar", dbBoolean, False
SetProperties "AllowFullMenus", dbBoolean, False 'Access Full Menus.
SetProperties "AllowSpecialKeys", dbBoolean, False 'F11,ALT F11, etc.
SetProperties "AllowBypassKey", dbBoolean, False 'Shift Key Override on loading
SetProperties "AllowShortcutMenus", dbBoolean, False 'Access ShortcutMenus. May be
too severe.
SetProperties "AllowToolbarChanges", dbBoolean, False 'Prevent Changes.
SetProperties "AllowBreakIntoCode", dbBoolean, False 'Code access.
DoCmd.ShowToolbar "ribbon", acToolbarNo
DoCmd.NavigateTo ("acnavigationcategoryobjecttype")
ThisError:
MsgBox Err.Description
Exit Function
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
‫ نیچے واال کوڈ کو‬ON LOAD FORM ‫میں استعمال کرنا ہے۔‬
DoCmd.ShowToolbar "ribbon", acToolbarNo
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''
Private Sub Command11_Click()

Call EnableSetProperty
MsgBox "All properties are enabled successfully"
DoCmd.Close acForm, Me.Name
End Sub
''''''''''''''''''
Private Sub Command12_Click()
Call DisableSetProperty
MsgBox "All properties are disabled successfully"
DoCmd.Close acForm, Me.Name
End Sub

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''
Private Sub txtUserName_DblClick(Cancel As Integer)
Dim strinput As String
strinput = InputBox("please enter the password", "enter Password")
If strinput = "Rafiq786" Then
DoCmd.OpenForm "Set_property"
Else
MsgBox "Invalid Password", vbInformation, "Invalid Password"
End If
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub btnLogin_Click()
Dim rs As Recordset

Set rs = CurrentDb.OpenRecordset("Login", dbOpenSnapshot, dbReadOnly)

rs.FindFirst "UserName='" & Me.txtUserName & "'"

If rs.NoMatch Then
Me.lblWrongUser.Visible = True
Me.txtUserName.SetFocus
Exit Sub
End If
Me.lblWrongUser.Visible = False

If rs!Password <> Nz(Me.txtPassword, "") Then


Me.lblWrongPass.Visible = True
Me.txtPassword.SetFocus
Exit Sub
End If
Me.lblWrongPass.Visible = False
DoCmd.OpenForm "Main_form"
DoCmd.Close acForm, Me.Name
End Sub
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Private Sub txtUserName_AfterUpdate()
Form_LoginFrm.Txtname.Value = DLookup("Name", "login", "username='" & txtUserName &
"'")
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub Form_Load()
DoCmd.ShowToolbar "ribbon", acToolbarNo
DoCmd.NavigateTo ("acnavigationcategoryobjecttype")
End Sub

You might also like