+ Reply to Thread
Results 1 to 5 of 5

How to change the code inside a userform by using another userform

Hybrid View

  1. #1
    Registered User
    Join Date
    04-27-2016
    Location
    Philippines
    MS-Off Ver
    MS Office 2016
    Posts
    28

    How to change the code inside a userform by using another userform

    So, I have a project that require login details, as an admin from time to time I want to allow as specific user to use the program by editing the login details inside a login userform code. I am planning to make another (admin)userform that can edit/change the code inside the login userform. Is it possible?

  2. #2
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: How to change the code inside a userform by using another userform

    Yes it is possible


    Kind regards
    Leo

  3. #3
    Registered User
    Join Date
    04-27-2016
    Location
    Philippines
    MS-Off Ver
    MS Office 2016
    Posts
    28

    Re: How to change the code inside a userform by using another userform

    Hi LeoTaxi, can you help me modify this code? I want to change the userpassword from another sub procedure.

    Private Sub Enter_Button_Click()
    
    Dim UserName As String
    Dim userpassword As String
    
    UserName = "User"
    userpassword = "Admin"
    
    If user_name <> UserName Then
    MsgBox "Invalid Username or Password", vbCritical, "SmartCAL"
    Exit Sub
    End If
    
    If password <> userpassword Then
    MsgBox "Invalid Username or Password", vbCritical, "SmartCAL"
    Exit Sub
    End If
    
    If user_name.Value = "" Then
    MsgBox "Username is missing", vbCritical, "SmartCAL"
    Exit Sub
    End If
    
    
    If password.Value = "" Then
    MsgBox "Password is missing", vbCritical, "SmartCAL"
    Exit Sub
    End If
    
    
    
    response = MsgBox("By logging in it is understood the you have read and accepted the disclaimer. Do you want to proceed using the program?", vbOKCancel + vbInformation, "SmartCAL - EULA")
    If response = vbCancel Then
    Exit Sub
    End If
    Login.Hide
    
    End Sub

    This is the code that supposed to changed the userpassword from "Sub Enter_Button_Click". I have set the new password in "Confirm_new" but the "userpassword" is outside of this below sub procedure.
    Private Sub change_Click()
    If old_pw.Text <> userpassword Then
    MsgBox "Invalid Old Password", vbCritical, "SmartCAL"
    Exit Sub
    End If
    
    
    If new_pw.Text <> Confirm_New Then
    MsgBox "New password does not match! Please re-type the new password again.", vbCritical, "Passwords mismatched!"
    Exit Sub
    End If
    
    
    response = MsgBox("Are you sure you want to change the existing password? Make sure to remember or note down the new password.", vbYesNo + vbInformation, "SmartCAL - Password Change")
    If response = vbNo Then Exit Sub
    user_name.Enabled = True
    password.Enabled = True
    Enter_Button.Enabled = True
    old_pw_lbl.Visible = False
    old_pw.Visible = False
    new_pw_lbl.Visible = False
    new_pw.Visible = False
    change.Visible = False
    MsgBox "Your password has been successfully changed!", vbInformation, "SmartCAL - Password Change"
    change_pw.Enabled = True
    change_rank.Enabled = True
    Cancel.Visible = False
    
    userpassword = Confirm_New.Value
    Confirm_new_lbl.Visible = False
    Confirm_New.Visible = False
    Last edited by king05; 02-19-2017 at 02:19 PM.

  4. #4
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: How to change the code inside a userform by using another userform

    How to do without a file ?

    cheers
    Leo

  5. #5
    Registered User
    Join Date
    04-27-2016
    Location
    Philippines
    MS-Off Ver
    MS Office 2016
    Posts
    28

    Post Re: How to change the code inside a userform by using another userform

    Hi Leo, have attached the file. Hope you could modify it for me.


    Thanks and Best regards,
    King

    [attach]UserLogin.xlsb[/attach]
    Attached Files Attached Files

+ 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. Replies: 2
    Last Post: 05-24-2016, 05:27 AM
  2. [SOLVED] change the code for userform
    By AKRAMI in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-10-2015, 06:49 AM
  3. Placing a userform inside another userform
    By thibodc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-21-2015, 10:20 PM
  4. [SOLVED] Change line of code using userform
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-13-2015, 05:32 AM
  5. [SOLVED] Need to change the caption of various labels inside a userform with a variable
    By navialivad in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-19-2014, 03:02 PM
  6. Change info of 3 Pivot Tables with a Userform (dummy workbook inside)
    By HendrixSpirit in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-13-2014, 08:42 AM
  7. Userform TextBox.Value inside Formula, in VBA code
    By schneij in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-23-2013, 06:03 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