creating username and password

G

Guest

Please i am new to access 2003 and would like to create a username and
password on a form that will open once the passwords are right.
Thanks.
 
G

Guest

Hi,
there are many ways of achieving this. If you really just want a simple
password protection on a form with one password you can use an input box on
click event of the button which opens this form e.g.:

Dim strInput As String
Dim strMsg As String

strMsg = "Please enter password?"
strInput = InputBox(Prompt:=strMsg, title:="Password Please!")
If strInput = "YourPassword" Then
DoCmd.OpenForm "FormName"
Else
MsgBox("Wrong password, try again!")
End If

If you want to use different usernames with special assigned passwords you
could create a table which holds the usernames and passwords. Then you can
use the dlookup function on the on click event of a button to compare the
entered values in your login form (username textbox and password textbox)
with the values stored in the table e.g.:

Dim varUser As Variant, varPW as Variant

varUser = DLookup("[UsernameField]","tblUsers","[UsernameField] = '" &
Me!UsernameControl & "'")
varPW = DLookup("[PasswordField]","tblUsers","[PasswordField] = '" &
Me!PasswordControl & "'")

If varUser = Me!UsernameControl AND varPW = Me!PasswordControl Then
DoCmd.Openform "FormName"
Else
MsgBox("Wrong password, try again!")
Me!UsernameControl.SetFocus
End If

These are just a couple of examples...if you want to clarify what you are
after and this doesn't help you then let me know.
HTH
Good luck
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top