Are you saying u want to prompt for a password on a click of a button.
Simplest way - using hardcoding, say your button was called cmdTest
-
private cmdTest_Click()
-
Dim sPswd as String
-
-
sPswd = NZ(InputBox("Enter Password"),"")
-
if sPswd <> "somevalue" then
-
msgbox "Password incorrect"
-
exit sub
-
else
-
'continue processing
-
end if
-
end sub
-
Now of course, its best to store passwords in a table somewhere, u may find u have different passwords for different things
So u could perform a dlookuo
-
private cmdTest_Click()
-
Dim sPswd as String
-
Dim sValidPswd as String
-
-
'Look up field pwd in table tblPassword
-
sValidPswd = DLOOKUP("pwd","tblPasswords")
-
sPswd = NZ(InputBox("Enter Password"),"")
-
-
if sPswd <> sValidPswd then
-
msgbox "Password incorrect"
-
exit sub
-
else
-
'continue processing
-
end if
-
end sub
-
U could also add criteria into your dlookup
'Look up field pwd in table tblPassword where field op = fred
sValidPswd = DLOOKUP("pwd","tblPasswords","op='fred'")
Of course using inputbox, u cannot mask the input. It is possible but u would need to make use of callback functions. Other way of course is to open up a form and do it.