+ Reply to Thread
Results 1 to 8 of 8

Password Issue

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Password Issue

    I have the following code:

    Private Sub cmdSubmit_Click()
    
        If Me.txtPassword.Value = "" Then
        Me.Hide
            retry = MsgBox("You must enter a password first.  Would you like to try again?", vbYesNo, "Retry?")
            Select Case retry
                Case vbYes
                    Me.txtPassword = ""
                    Me.txtPassword.SetFocus
                    Me.Show
                Case vbNo
                    Unload Me
            End Select
            End If
            
            
       If Me.txtPassword.Value = "regional" Then
            Unload Me
            Sheets("DATABASE").Visible = True
            Sheets("DATABASE").Select
        Else
            Me.Hide
            retry = MsgBox("The password is incorrect.  Would you like to try again?", vbYesNo, "Retry?")
            Select Case retry
                Case vbYes
                    Me.txtPassword = ""
                    Me.txtPassword.SetFocus
                    Me.Show
                Case vbNo
                    Unload Me
            End Select
        End If
    
    
    Dim lastrow As Long
    
    With Sheets("DATABASE")
      lastrow = .Range("A2").End(xlDown).Row
      .Cells(lastrow + 1, 1).Value = txtLastName.Text & ", " & txtFirstName.Text
      .Cells(lastrow + 1, 2).Value = txtCCN.Text
      .Cells(lastrow + 1, 3).Value = txtDateofhire.Text
      .Cells(lastrow, 4).Resize(1, 6).Copy .Cells(lastrow + 1, 4)
    End With
    Application.CutCopyMode = False
    
    txtFirstName = ""
    txtLastName = ""
    txtCCN = ""
    txtDateofhire = ""
    
    
    End Sub
    which is to require a password prior to submitting the form. It works except if the User selects NO during the first section of code (where it says you must enter a password). I am getting an Automation error that says the Calle(Server is not available. Any ideas?

  2. #2
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Password Issue

    Hi,

    It's a bit difficult without seeing your workbook, but please try changing "Me" to the name of the userform. This probably isn't likely to solve your issue, but worth a try.

    If this fails, can you please upload your workbook.

    Thanks

  3. #3
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Password Issue

    What about changing the top portion of the code and not giving a NO option. Just a box stating You Must Enter a Password First with OK only.

    If so, how would I do that? I copied this code from somewhere else, and I don't want to remove too much.

  4. #4
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Password Issue

    The Me.Hide part was working fine when I used a password in another place. I cannot attach the workbook as it has a few hundred employee names

  5. #5
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Password Issue

    It's hard to say without seeing the workbook. Is there any way you could desensitise the workbook, or maybe just send a small sample?

    It should work with a Yes and a No option

  6. #6
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Password Issue

    Add an Exit line:
    Case vbNo
        Unload Me
        Exit Sub
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  7. #7
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Password Issue

    Isn't that already there?

  8. #8
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Password Issue

    Quote Originally Posted by tapsmiled View Post
    Isn't that already there?
    Not in the code you posted.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Issue with textbox password?????
    By ciapul12 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-15-2014, 10:23 AM
  2. [SOLVED] Password protection issue
    By Bjordion in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-13-2012, 12:07 PM
  3. VBA Password issue
    By Topguy in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-15-2010, 10:29 AM
  4. User Name & Password Log In Issue
    By KLahvic in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-11-2009, 10:59 AM
  5. Password Issue
    By keithl816 in forum Excel General
    Replies: 6
    Last Post: 07-10-2005, 02:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1