Solved

VBA - Login Script

Posted on 2006-07-05
1
786 Views
Last Modified: 2008-03-17
I have taken over some coding from someone and am getting a little confused with some of the methids they have used. I have the following script which should look at a text box called txtName and a password bov called txtPassword, and chech to see if the user has enetered in the ocrrect details. Once the user clicks on the image labelled imgContinue they should be able to know if they have succesfully ligged into the system or not. Could someone please check the code and offer some help of where the code or I have gone wrong. As I have said i am trying to combine my own code along with another coders.

Thanks

Option Compare Database
Option Explicit

Private Sub Form_Load()
'on load maxmise this form
DoCmd.Maximize

End Sub

Private Sub imgContiniue_Click()

'on the click of the continue button
On Error GoTo Err_cmdContinue_Click

Dim username As String
Dim stDocName As String
Dim stLinkCriteria As String
Dim Userstat As String

    'define target form
    stDocName = "frmMainMenu"
    'open target form
    DoCmd.Maximize
   
    'Userstat = Me.UserStatus.Caption
    stDocName = "connekt4"
   
    On Error Resume Next
   
    username = Me.txtName

    If Me.imgContinue_Active.Visible = True Then
   
        Application.Echo False
        DoCmd.Hourglass True
            'if the password is right then on click of the blue continue display buttons
           
            Me.imgContinue_Active.Visible = False
            Me.imgContinueUnactive.Visible = False
           
            'check to see if the user can have access to the administration screen
               
                'Client_SQL_Search.startClientDetails
                DoCmd.Close acForm, "Form_frmFlash"
                DoCmd.OpenForm stDocName, , , stLinkCriteria
                     
                Application.Echo True
                DoCmd.Hourglass False
    End If
               
 ' if the password is wrong then bring up error message
    If Me.imgContinue_Active.Visible = False Then

        Me.txtPassword.SetFocus

    End If
   
Exit_cmdContinue_Click:
    Exit Sub

Err_cmdContinue_Click:
'error code
    MsgBox Err.Description
    Resume Exit_cmdContinue_Click

End Sub

Private Sub cmdChangePassword_Click()
Application.Echo False
DoCmd.Hourglass True

DoCmd.Close acForm, "Form_frmFlash"
DoCmd.OpenForm "UserSetup"
With Form_UserSetup
.RecordsetType = 0
.Licencee_Name.Locked = False
.fldUserName.Locked = False
.UserPassword.Locked = False
Application.Echo True
DoCmd.Hourglass False
.Licencee_Name.SetFocus
End With
End Sub

Private Sub cmdclose_click()

'dialog box to continue
Dim message As String
Dim buttonsandicons As Integer
Dim title As String
Dim Response As Integer

'the message of the dialog box
message = "Do you want to exit Connekt4?"

'the title of the dialog box
title = "Exit Connekt4"

'the look of the dialog box
buttonsandicons = vbYesNo + vbQuestion

'displaay dialog and get users response
Response = MsgBox(message, buttonsandicons, title)

'evaluate the user's response
If Response = vbNo Then

End

Else

DoCmd.Quit
End If
End Sub

Private Sub cmdcontinue_Click()
Dim username As String
Dim stDocName As String
Dim stLinkCriteria As String
Dim Userstat As String
   
    'Userstat = Me.UserStatus.Caption
    stDocName = "connekt4"
    On Error Resume Next
   
    username = Me.txtName

If Me.imgContinue_Active.Visible = True Then
Application.Echo False
DoCmd.Hourglass True
    'if the password is right then on click of the blue continue display buttons
   
    'Me.cmdContinue.Visible = False
    Me.imgContinue_Active.Visible = False
    Me.imgContinueUnactive.Visible = False
   
    'check to see if the user can have access to the administration screen
       
            'Client_SQL_Search.startClientDetails
            DoCmd.Close acForm, "Form_frmFlash"
            DoCmd.OpenForm stDocName, , , stLinkCriteria
             
             Application.Echo True
            DoCmd.Hourglass False
End If
               
 ' if the password is wrong then bring up error message
If Me.imgContinue_Active.Visible = False Then

        Me.txtPassword.SetFocus

        End If

   
End Sub

Private Sub cmdHelp_Click()
Dim HlpPth As String

HlpPth = Application_Paths.HlpPth

Me.cmdHelp.HyperlinkAddress = HlpPth

End Sub


Private Sub cmdOpenMainSys_Click()
On Error GoTo Err_cmdOpenMainSys_Click

    Dim stDocName As String
    Dim stLinkCriteria As String
    Dim Userstat As String
     Application.Echo False
DoCmd.Hourglass True
    Userstat = Me.UserStatus.Caption
   
'form_Clients.RecordSource = Client_SQL_Search.startClientDetails
    stDocName = "Connekt4"
    'set mainsystems record source to a's
    Client_SQL_Search.startClientDetails
    DoCmd.Close acForm, "Form_frmFlash"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
     Application.Echo True
DoCmd.Hourglass False
 
   

Exit_cmdOpenMainSys_Click:
    Exit Sub

Err_cmdOpenMainSys_Click:
    MsgBox Err.Description
    Resume Exit_cmdOpenMainSys_Click
   
End Sub

Private Sub txtPassWord_AfterUpdate()
If Me.txtPassword.Value = "sysadm" Then
    'cmdContinue.Visible = True
    imgContinue_Active.Visible = True
    imgContinueUnactive.Visible = False
    cmdChangePassword.Visible = True
    End
Else

    If Me.txtPassword.Value = "5J6Y19" Then
        'cmdContinue.Visible = True
        imgContinue_Active.Visible = True
        imgContinueUnactive.Visible = False
        cmdChangePassword.Visible = True
        End
   
Else
    If Me.txtName.Value = Me.fldUserName Then
        If Me.txtPassword.Value = Me.UserPassword Then
            'cmdContinue.Visible = True
            imgContinue_Active.Visible = True
            imgContinueUnactive.Visible = False
            End
            Else
            MsgBox "You have entered an incorrect user name or password", vbOKOnly, "Incorrect User Name or Password"
            Me.txtName.SetFocus
        End If
   
Else
    MsgBox "You have entered an incorrect user name or password", vbOKOnly, "Incorrect User Name or Password"
    Me.txtName.SetFocus
       
    End If
    End If
End If
End Sub

0
Comment
Question by:andyb7901
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 5

Accepted Solution

by:
MageDribble earned 500 total points
ID: 17044716
This is a duplicate question.  You also posted this in the Access section.

http://www.experts-exchange.com/Databases/MS_Access/Q_21908997.html
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question