Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Password to a form. How to change it dynamically?

Status
Not open for further replies.

pkn

IS-IT--Management
Sep 15, 2001
1
DK
Hello all!!

I have a database in which the user should enter a password to move from one form to other. Here is the code which prompts for a password. I wish to give the user an option to change the password. I made a password table with one column in which the password will be stored. Would anyone suggest me how to alter the following code. i.e How to retrieve the password from the Password table into this? Right now, the password is static(Shown in the code). The access version is 2000. Passbut is the button, when clicked gives a password prompt. "Medical" is the form to which Password protection is given.
Any help/code would be greatly appreciated.
P.S. I don't have the docmd.database option here.

Thanks
pkn



Private Sub PassBut_Click()
On Error GoTo Err_PassBut_Click

Dim stDocName As String
Dim stLinkCriteria As String
If InputBox("Enter Password to view medical information", "Enter Your Password") = "usa" Then
stDocName = "Medical"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Maximize
End If

Exit_PassBut_Click:
Exit Sub

Err_PassBut_Click:
MsgBox Err.Description
Resume Exit_PassBut_Click
End Sub
 
If you have a table to store the password all you need to do is something like this:

Open a recordset referring to the password table, e.g.

Dim Dbs as Database, Rst as Recordset
Set Dbs=CurrentDb()
Set Rst=Dbs.OpenRecordset("Password",dbOpenSnapshot)
Rst.Movefirst

Replace the If InputBox("Enter Password to view medical information", "Enter Your Password") = "usa" Then

to something like

If InputBox("Enter Password to view medical information", "Enter Your Password") = Rst.Fields(0).Value Then

If the passowrd is changed then the code will now reference the new password.

Alex Middleton
 
Hi!!

I tried this.. But, it points to the Dim dbs as Database and gives the error: User-defined type not defined. Would you please tell me what it is?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top