Solved

VBA - Login Script

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

815 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

8 Experts available now in Live!

Get 1:1 Help Now