Solved

VBA - Login Script

Posted on 2006-07-05
1
775 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
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now