C
Carola Hiddink
Hi everybody,
Based on a previous question by another sender, I have
programmed the below mentioned code. It works perfect,
except for one thing that I want to add, but cannot figure
out how to do that.
What I want is the following: I have a table that is
called Table1 that contains multiple data entrist names
and passwords. I want to be able to have a "simple"
security, by using a login form (FORM2) where the data
entrist has to type his/her name and his/her password.
This name and password then needs to be compared with the
name and password in Table1, and if the same, login is
accepted.
(The "real" security is done in a later stage, for now I
want to keep it simple !)
However, with the code I am having here, ANY of the
multiple passwords in the table if found to be correct,
not just the one that is mentioned behind the certain data
entrist name.
So: what do I need to add to the program to get that
done ? I am not really handy with programming Visual Basic
yet, but I think I'm well on the way of understanding...
Thanks a lot !!!
______________________________________________________
Private Sub Next_Click()
On Error GoTo Err_Next_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim found As String
found = Nz(DLookup("[PASSWD]", "[Table1]", "[PASSWD]
='" & Forms![Form2]![PASSWD] & "'"), "false")
If found <> "false" Then
MsgBox "Password is correct"
stDocName = "Subject number"
DoCmd.OpenForm stDocName, , , stLinkCriteria, , ,
Me.Name
Me.Visible = False
Else
MsgBox "Password is incorrect"
DoCmd.Close
End If
Exit_Next_Click:
Exit Sub
Err_Next_Click:
MsgBox Err.Description
Resume Exit_Next_Click
End Sub
Based on a previous question by another sender, I have
programmed the below mentioned code. It works perfect,
except for one thing that I want to add, but cannot figure
out how to do that.
What I want is the following: I have a table that is
called Table1 that contains multiple data entrist names
and passwords. I want to be able to have a "simple"
security, by using a login form (FORM2) where the data
entrist has to type his/her name and his/her password.
This name and password then needs to be compared with the
name and password in Table1, and if the same, login is
accepted.
(The "real" security is done in a later stage, for now I
want to keep it simple !)
However, with the code I am having here, ANY of the
multiple passwords in the table if found to be correct,
not just the one that is mentioned behind the certain data
entrist name.
So: what do I need to add to the program to get that
done ? I am not really handy with programming Visual Basic
yet, but I think I'm well on the way of understanding...
Thanks a lot !!!
______________________________________________________
Private Sub Next_Click()
On Error GoTo Err_Next_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim found As String
found = Nz(DLookup("[PASSWD]", "[Table1]", "[PASSWD]
='" & Forms![Form2]![PASSWD] & "'"), "false")
If found <> "false" Then
MsgBox "Password is correct"
stDocName = "Subject number"
DoCmd.OpenForm stDocName, , , stLinkCriteria, , ,
Me.Name
Me.Visible = False
Else
MsgBox "Password is incorrect"
DoCmd.Close
End If
Exit_Next_Click:
Exit Sub
Err_Next_Click:
MsgBox Err.Description
Resume Exit_Next_Click
End Sub