Example from your workbook.
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
sUserID = TextBox1.Value
sPword = TextBox2.Value
SaveSetting "YourApp", "Variables", "UserID", sUserID
SaveSetting "YourApp", "Variables", "Pword", sPword
SaveSetting "YourApp", "Variables", "ChkBox1", True
End If
End Sub
Private Sub Close1_Click()
Unload Me
End Sub
Private Sub OK_Click()
sUserID = TextBox1.Value
sPword = TextBox2.Value
If CheckBox1.Value = True Then
sUserID = TextBox1.Value
sPword = TextBox2.Value
SaveSetting "YourApp", "Variables", "UserID", sUserID
SaveSetting "YourApp", "Variables", "Pword", sPword
SaveSetting "YourApp", "Variables", "ChkBox1", True
Else
SaveSetting "YourApp", "Variables", "UserID", ""
SaveSetting "YourApp", "Variables", "Pword", ""
SaveSetting "YourApp", "Variables", "ChkBox1", False
End If
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim sUserID As String
Dim sPword As String
sUserID = GetSetting("YourApp", "Variables", "UserID")
sPword = GetSetting("YourApp", "Variables", "Pword")
TextBox1.Value = sUserID
TextBox2.Value = sPword
End Sub
This saves the UserID and Pword to the registry if CheckBox1 is true, if false the values saved are removed. TextBox1 and 2 will have the values displayed while textbox2 are encrypted ("*"). Everytime a user opens the app fire the userform adn as long as they select checkbox one as true, the UserID and Pword will remain the same.
I also set values for CheckBox1 if its true or false.
From this you can work from actual user login of the computer if you need authorization to be more indepth.
HTH
Bookmarks