?
Solved

VBA - Login Script

Posted on 2006-07-05
1
Medium Priority
?
799 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 1000 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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 …
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

719 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