Hello everyone.
I have been trying to look for working codes for the userform to work flawlessly. Unfortunately, I couldn't find any code. I just wish you could help me how to do this. I have a sheet named "DATABASE" with names of schools in column A, school ID in column B, and password in column C.
The combobox (cboStation) is populated already with the list of schools. What I need to do now is when a user select a specific school from the cboStation, the user can input the corresponding school id in the Textbox1. When Textbox1 matches with the selection in the cboStation, the password will be enabled. This means that when cboStation and Textbox1 don't match, the password area is disabled.
Below are the codes within the userform:
Private Sub UserForm_Initialize()
cboStation.SetFocus
Dim v, e
With Sheets("DATABASE").Range("A2:A1000")
v = .Value
End With
With CreateObject("scripting.dictionary")
.comparemode = 1
For Each e In v
If Not .exists(e) Then .Add e, Nothing
Next
If .Count Then Me.cboStation.List = Application.Transpose(.keys)
End With
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then
Cancel = True
MsgBox "The X is disabled. Click CANCEL to Exit.", vbCritical, "BETA VERSION"
End If
End Sub
Private Sub cancelbot_Click()
Unload Me
SaveChanges = False
End Sub
Bookmarks