Results 1 to 3 of 3
  1. #1
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    528

    button a form to open But with password

    Hello guys
    I have a button on a form to open another form, what I want to when you press the button it shows me prompt to enter a password so I can watch the other form.


    Thank you .

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    If you are on network, you can use LOGIN AUTHENTICATION...

    Code:
    Public Sub BUTTON1_CLICK()
    if WindowsLogin() then  docmd.openForm "frmSecretForm"
    End sub
    
    
    Public Function WindowsLogin(ByVal strUserName As String, ByVal strpassword As String, ByVal strDomain As String) As Boolean
            'Authenticates user and password entered with Active Directory.
    
            On Error GoTo IncorrectPassword
            
            Dim oADsObject, oADsNamespace As Object
            Dim strADsPath As String
            
            strADsPath = "WinNT://" & strDomain
            Set oADsObject = GetObject(strADsPath)
            Set oADsNamespace = GetObject("WinNT:")
            Set oADsObject = oADsNamespace.OpenDSObject(strADsPath, strDomain & "\" & strUserName, strpassword, 0)
            
            WindowsLogin = True    'ACCESS GRANTED
            
    ExitSub:
            Exit Function
            
    IncorrectPassword:
            WindowsLogin = False   'ACCESS DENIED
            Resume ExitSub
    End Function

  3. #3
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    528
    Thank you ranman256
    I use this code
    But how do I convert the letters to the Star
    Code:
    Dim strInput As String
    Dim strMsg As String
    Beep
    strMsg = "Please Enter the password to allow access."
    strInput = InputBox(Prompt:=strMsg, Title:="Special Password")
    If strInput = "12345" Then 'password is correct
    DoCmd.OpenForm "Parts", acFormDS, "", "", , acNormal
    DoCmd.Close acForm, Me.Name
    Else 'password is incorrect
    MsgBox "Incorrect Password!" & vbCrLf & vbLf & "You are not allowed access to the ''sales form''.", vbCritical, "Invalid Password"
    Exit Sub
    End If
    Attached Thumbnails Attached Thumbnails 2333.JPG  

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 01-15-2014, 07:57 PM
  2. Replies: 1
    Last Post: 12-03-2013, 01:38 PM
  3. Replies: 5
    Last Post: 11-26-2013, 09:20 AM
  4. Replies: 1
    Last Post: 05-31-2013, 08:53 AM
  5. cmd button to open form
    By stephaniehpcswf in forum Access
    Replies: 1
    Last Post: 02-23-2011, 04:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums