Solved login form

mansied

Member
Local time
Today, 11:43
Joined
Oct 15, 2020
Messages
100
HELLO
I have a databse with a table to give access user to login .but it have an error that i can solve it ,anyone can help me to find the issue ?

Private Sub Command1_Click()
If IsNull(Me.txtBnumber) Then
MsgBox "Please enter your Bnumber to proceed."
Me.txtBnumber.SetFocus
Else
'process the job
If (IsNull(DLookup("User Bnumber", "Authorised Users", "User Bnumber = '" & Me.txtBnumber.Value & "'"))) Then
MsgBox "You do not have access to the database."
Else
MsgBox "Login accepted."
End If
End If

End Sub


1633702226749.png
 

Attachments

Hi. For those of us who can't download your file right now, what was the error message?
 
Don't have spaces in fields,controls and table names :-(
Code:
Private Sub Command1_Click()
If IsNull(Me.txtBnumber) Then
    MsgBox "Please enter your Bnumber to proceed."
    Me.txtBnumber.SetFocus
Else
    'process the job
    If IsNull(DLookup("[User Bnumber]", "[Authorised Users]", "[User Bnumber] = '" & Me.txtBnumber & "'")) Then
        MsgBox "You do not have access to the database."
    Else
        MsgBox "Login accepted."
    End If
End If

End Sub
 
Don't bother the user with this line of code...
Code:
MsgBox "Login accepted."
You're just adding a valueless click to their workflow.
 
Be careful with this authorisation technique.

Once you have made the corrections suggested by Gasman, it will be possible to log in to your application by typing as Bnumber:
' OR '1' = '1

😲
 
Mitigate the issue by:
Code:
' ...
    'process the job
    If (IsNull(DLookup("[User Bnumber]", "[Authorised Users]", "[User Bnumber] = '" & Replace(Me.txtBnumber.Value, "'", "''") & "'"))) Then
' ...
 

Users who are viewing this thread

Back
Top Bottom