+ Reply to Thread
Results 1 to 5 of 5

Password for custom userform login only works with text passwords

  1. #1
    Forum Contributor
    Join Date
    09-16-2013
    Location
    Los Angeles, USA
    MS-Off Ver
    Excel 2011
    Posts
    620

    Password for custom userform login only works with text passwords

    Im using the following code on a User login userform. This code is for the Login command button to access the workbook (the user clicks on it after entering there username and password).
    For some reason if the password is numbers only it just returns message box "Incorrect password, please try again."
    As soon as I put a single letter into the password it works fine, I can't figure out why.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    11-26-2013
    Location
    Colac, Victoria, Australia
    MS-Off Ver
    Excel 2016
    Posts
    1,309

    Re: Password for custom userform login only works with text passwords

    Just a thought, you have declared PW as a STRING. I think that when excel sees a number, it says it is not valid!

    Try removing the "as String" from the Dim statement. Excel will then treat it as a Variant, and allow anything to be entered.

    Please let me know if this works!

    Regards,

    David


    When you reply please make it clear WHO you are responding to by mentioning their name.

    If this has been of assistance, please advise. A little thanks goes a long way.
    - Please click on the *Add Reputation button at the bottom of helpful responses.

    Please mark your thread as SOLVED:
    - Click Thread Tools above your first post, select "Mark your thread as Solved".

  3. #3
    Forum Contributor
    Join Date
    09-16-2013
    Location
    Los Angeles, USA
    MS-Off Ver
    Excel 2011
    Posts
    620

    Re: Password for custom userform login only works with text passwords

    Thanks for the response David, but that didn't seem to affect it.

  4. #4
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Password for custom userform login only works with text passwords

    Hi James,

    I think your problem may be in the Spreadsheet and not in the UserForm. I think you should probably format the Spreadsheet cells as text. Without previous formatting text is displayed as left justified and numbers are displayed as right justified in the spreadsheet.

    1. You might want to try retrieving the data from the Spreadsheet as text. In my applications that require numeric values in cells, I usually read them as text first and then convert to numbers in order to catch bad values in the spreadsheet without having to use 'on error'.

    Try replacing:
    Please Login or Register  to view this content.
    with something like:
    Please Login or Register  to view this content.

    2. Alternatively, without modifying the spreadsheet, you could convert both the actual password and the user entered password to strings such as:
    Please Login or Register  to view this content.
    If this doesn't work there are more complicated scenarios that you can use.

    Lewis
    Last edited by LJMetzger; 03-23-2014 at 11:13 PM. Reason: Added alternative 1. after thinking more clearly; aternataive 2 was in original.

  5. #5
    Forum Contributor
    Join Date
    09-16-2013
    Location
    Los Angeles, USA
    MS-Off Ver
    Excel 2011
    Posts
    620

    Re: Password for custom userform login only works with text passwords

    Thanks Lewis, that first option your gave me works just fine.

+ 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. Username/Password Login userform code
    By Nitefox in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-17-2014, 02:43 PM
  2. How to create a password login through a userform
    By xia0jj in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 01-10-2014, 05:59 AM
  3. Please help Password protecting different sheets with different passwords
    By Joshua28 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-24-2012, 11:01 AM
  4. Password Protect - Multiple Passwords
    By aspears in forum Excel General
    Replies: 0
    Last Post: 12-08-2008, 01:12 PM
  5. [SOLVED] Multiple Passwords and Maste Password
    By Lucas in forum Excel General
    Replies: 1
    Last Post: 04-02-2005, 06:07 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