On a form . . .
VB Code:
Option Explicit Public i As Integer Private Sub cmdOk_Click() i = i + 1 If i = 3 Then MsgBox "Sorry, three strikes and your out!" Unload Me Exit Sub End If If txtPassword.Text <> strPword Then MsgBox "Incorrect password!" & VBA.vbCr & VBA.vbCr & _ "Make sure caps lock is not on" & VBA.vbCr & _ " and try again", vbInformation + vbOKOnly, "Incorrect Password" Exit Sub Else 'password succeeded 'put code here to continue after password success End If End Sub Private Sub cmdCancel_Click() Unload Me End Sub
. . . in a module . . .
VB Code:
Option Explicit Public Const strPword As String = "chickenmcnugget" 'replace that password with whatever you choose 'don't forget to password protect your project!! Sub Get_Password() frmPword.Show End Sub
. . . and here is the form . . .
Good luck !
(I created that form in ExcelXP so you can import it directly into your project)




Reply With Quote