Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to give password to a form? 7

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi all!

Is it possible to give password protection to a form? I mean, password protection to a form while navigating between forms. Any help would be greatly appreciated

Thanks
 
I use this code when I press a command button to open a maintenance form. You can apply this code almost antplace

Private Sub Maintenance_Click()
On Error GoTo Err_maintenance_Click

Dim stDocName As String
Dim stLinkCriteria As String
If InputBox("Enter Password for Directory Maintenance", "Enter Your Password") = "dave" Then
stDocName = "frmMaintenanceMenu"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Maximize
End If


Exit_maintenance_Click:
Exit Sub

Err_maintenance_Click:
MsgBox Err.Description
Resume Exit_maintenance_Click
End Sub

HTH
 
Another way to do this is to make a form which allows you to use the password input mask so no one can peek over your shoulder and read the password. I have a form where after you enter the password it enables a command button to open the form I want restricted from general use.
 
I have this on the after update event of a textbox which lives on my password form. Its not elegant but it seems to work ok.


Private Sub passtext_AfterUpdate()
If Me!passtext = "password" Then
Me![open config].Enabled = True
Else
Me![open config].Enabled = False
End If
End Sub
 
Most applications need simple management tools to allow adding and deleting users. My suggestion would be to build a table that has the data for the individuals you would like to extend access to this specific form.

Table can include the following
pkeyId = AutoNumber
strUserNam = Text
strUserId = Text
strPw = Text

Once this is completed design an unbound form with a combo box (cboUserId) for the User Id list and a text box (txtPw) for to validate password with User ID. Add a command button (cmdOpenFrm) and in the On Click event enter the following code:

Private Sub cmdOpenFrm_Click()
Dim intLogonAttempts As Integer

If IsNull(cboUserID) = True Then
MsgBox "Please select user name from drop down.", vbOKOnly, "Invalid User!"
Me.cboUserID.SetFocus
End If

If IsNull(cboPw) = True Then
MsgBox "Please enter correct password.",vbOKOnly, "Invalid Password!"
Me.cboPw.SetFocus
End If

If Me.cboPw.Value = DLookup("strPw", "TABLE NAME", "[pkeyID] =" & Me.cboUserID.Value) Then
cboUserID = Me.cboUserID.Value
DoCmd.Close acForm, "PASSWORD FORM", acSaveNo
DoCmd.OpenForm "DESTINATION FORM"
Else
MsgBox "Password Invalid. Please Try Again.", vbOKOnly, "Invalid Entry!"
Me.cboPw.SetFocus
End If

intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 2 Then
MsgBox "You do not have access to this database. Please contact database administrator!"
DoCmd.Close
End If
End Sub

You can comment out the intLogonAttempts if you choose to. This option actually limits the number of attempts to 3. If the user does not complete the password validation within the allowed attempts, the application will be closed.

Good luck.
 
Could determine which forms or even which post a certain person should have access to?

Best Regardz,

Spikemannen
 
There are a couple of approaches to this question, however the easiest and, what I feel to be the most efficient solution, is to attach the string to the Open Event of each form or build a module and referrence the module on the Open Event.

Hope this helps.

Spencer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top