Login screen compile error '3075' (syntax error)

M

Mr.Kane

Here si my dilemma:

I am creating a login screen for a small Access based app.
There is a combobox control where a user can select their name
and then they are required to enter a password (I have this set to a
default string currently)

The user then enables an "OK" command button whose "On Click" event
procedure is coded as the following:

Private Sub LogIn_OK_Button_Click()

Dim LogIn_ID As String
Dim Staff_ID As Single

'Check to see if data is entered into the UserName combo box
If IsNull(Me.LogIn_ID) Or Me.LogIn_ID = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.LogIn_ID.SetFocus
Exit Sub
End If

'Check to see if data is entered into the password box
If IsNull(Me.LogIn_PW) Or Me.LogIn_PW = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.LogIn_PW.SetFocus
Exit Sub
End If

'Check value of password in Staff to see if this matches value chosen
in combo box
If Me.LogIn_PW.Value = DLookup("Staff_Password", "tblStaff",
"[Staff_ID]"= "Me.LogIn_ID.Value") Then
Staff_Name = Me.LogIn_ID.Value

'Close logon form and open splash screen

DoCmd.Close acForm, "frmFOCUS-PRO Login Screen", acSaveNo
DoCmd.OpenForm "frmFOCUS-PRO (Front End)"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.LogIn_PW.SetFocus
End If


End Sub

"LogIn_PW" is the password text box control
"LogIn_ID" is the Username Combobox control


When the command button is clicked it returns the message "Password
Invalid. Please Try Again"

I'm sure that I have missed something obvious in my code. The procedure
isn't comparing the correct values to hose found in my "Security" Table

"Security" Table structure:
Staff_ID Staff_Name Team_ID Staff_Password


Btw the query that is feeding the LogIn_ID combobox it's values is
SELECT DISTINCT Security_Staff.Staff_Name, Min(Security_Staff.Staff_ID)
AS MinOfStaff_ID
FROM Security_Staff
GROUP BY Security_Staff.Staff_Name
ORDER BY Security_Staff.Staff_Name;


Any help would be appreciated
 
R

ruralguy via AccessMonster.com

I see at least two problems:

If Me.LogIn_PW = DLookup("Staff_Password", "tblStaff",
"[Staff_ID] =" & Chr(34) & Me.LogIn_ID & & Chr(34) & ") Then
Staff_Name = Me.LogIn_ID

The .Value property is the default property and need not be specified.

Staff_Name has not been defined so I suspect you do *not* have Option
Explicit at the top of your module. You have also defined Staff_ID as Single
at the beginning of the Sub and yet you do not reference it anywhere within
the sub. It also appears that [Staff_ID] is a field in the tblStaff table
and you probably do *not* want a variable in your Sub with the same name!


Mr.Kane said:
Here si my dilemma:

I am creating a login screen for a small Access based app.
There is a combobox control where a user can select their name
and then they are required to enter a password (I have this set to a
default string currently)

The user then enables an "OK" command button whose "On Click" event
procedure is coded as the following:

Private Sub LogIn_OK_Button_Click()

Dim LogIn_ID As String
Dim Staff_ID As Single

'Check to see if data is entered into the UserName combo box
If IsNull(Me.LogIn_ID) Or Me.LogIn_ID = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.LogIn_ID.SetFocus
Exit Sub
End If

'Check to see if data is entered into the password box
If IsNull(Me.LogIn_PW) Or Me.LogIn_PW = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.LogIn_PW.SetFocus
Exit Sub
End If

'Check value of password in Staff to see if this matches value chosen
in combo box
If Me.LogIn_PW.Value = DLookup("Staff_Password", "tblStaff",
"[Staff_ID]"= "Me.LogIn_ID.Value") Then
Staff_Name = Me.LogIn_ID.Value

'Close logon form and open splash screen

DoCmd.Close acForm, "frmFOCUS-PRO Login Screen", acSaveNo
DoCmd.OpenForm "frmFOCUS-PRO (Front End)"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.LogIn_PW.SetFocus
End If

End Sub

"LogIn_PW" is the password text box control
"LogIn_ID" is the Username Combobox control

When the command button is clicked it returns the message "Password
Invalid. Please Try Again"

I'm sure that I have missed something obvious in my code. The procedure
isn't comparing the correct values to hose found in my "Security" Table

"Security" Table structure:
Staff_ID Staff_Name Team_ID Staff_Password

Btw the query that is feeding the LogIn_ID combobox it's values is
SELECT DISTINCT Security_Staff.Staff_Name, Min(Security_Staff.Staff_ID)
AS MinOfStaff_ID
FROM Security_Staff
GROUP BY Security_Staff.Staff_Name
ORDER BY Security_Staff.Staff_Name;

Any help would be appreciated
 

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

Similar Threads

Login screen validation error 1
list separator or ) 4
list separator or ) 11
Syntax error 6
Run Time Error 3075 2
Filter Based on Log On 1
username and password form 3
Login Help! 2

Top