How to create a User Login Form

R

ryguy7272

I’m trying to run the code here:
http://www.databasedev.co.uk/login.html

Sometime seems to be not quite right. I have a table called ‘tblLogin’ with
the following fields ID, Login, Password, Email, Name, and Level.

I modified the original code slightly, so my code is now:
If Me.txtPassword.Value = DLookup("Login", "tblLogin", _
"[Login]=" & Me.cboEmployee.Value) Then

And, this is where the error occurs.
The message reads: ‘Run-time error: The expression you entered as a query
parameter produced this error ‘brooks’’. This ‘brooks’ is one of the names
in the tblLogin.


My table is named tblLogin,

My ComboBox uses FieldName ‘Login’.

Also, my ComboBox is maned ‘cboEmployee’ and it uses this as the RowSource:
SELECT DISTINCT tblLogin.Login FROM tblLogin ORDER BY tblLogin.Login;


Below is all the code, if it helps; it is mostly like the code on the
site…modified slightly for my data tables and my field names.


It must be something pretty simple; I just don’t see it and this is the
first time I have done such a thing. What am I missing here? Any help would
be greatly appreciated!!

Regards,
Ryan---
 
R

ryguy7272

There is a slight difference between the example on the web, and my own
version. The version of the web uses this:
The drop-down list sources the information using an SQL command:

SELECT [tblEmployees].[lngEmpID], [tblEmployees].[strEmpName]
FROM tblEmployees;

This returns the Employee ID number and the Employee name, however only the
Employee name is displayed (using the column width's property of 0cm;1cm. The
column bound to the database table is column 1 (lngEmpID).

I used this:
SELECT DISTINCT tblLogin.Login FROM tblLogin ORDER BY tblLogin.Login;
My Bound Column is 1 (just like the web example).
Finally, my Column Width Property blank (the web example uses column width's
property of 0cm;1cm...but if I did this I wouldn't see anything in the
ComboBox when I click on the down arrow). I'd appreciate any and all help
with this.

Regards,
Ryan---
 
J

John Spencer

I suspect that Login is a text field and that you really want to get the
Password returned by Dlookup. You need to surround the value of CboEmployee
with quote marks so it is treated as a string.

If Me.txtPassword.Value = DLookup("Password", "tblLogin", _
"[Login]=""" & Me.cboEmployee.Value & """") Then

Or use - Note this will error with a name like O'Bryan since Access will think
the string has been terminated after the 0.

If Me.txtPassword.Value = DLookup("Password", "tblLogin", _
"[Login]='" & Me.cboEmployee.Value & "'") Then

Or use

If Me.txtPassword.Value = DLookup("Password", "tblLogin", _
"[Login]=" & chr(34) & Me.cboEmployee.Value & Chr(34)) Then


John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
 
R

ryguy7272

These strings tripped me up before, in Excel. Awesome!! Thanks so much!!
Regards,
Ryan---

--
RyGuy


John Spencer said:
I suspect that Login is a text field and that you really want to get the
Password returned by Dlookup. You need to surround the value of CboEmployee
with quote marks so it is treated as a string.

If Me.txtPassword.Value = DLookup("Password", "tblLogin", _
"[Login]=""" & Me.cboEmployee.Value & """") Then

Or use - Note this will error with a name like O'Bryan since Access will think
the string has been terminated after the 0.

If Me.txtPassword.Value = DLookup("Password", "tblLogin", _
"[Login]='" & Me.cboEmployee.Value & "'") Then

Or use

If Me.txtPassword.Value = DLookup("Password", "tblLogin", _
"[Login]=" & chr(34) & Me.cboEmployee.Value & Chr(34)) Then


John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
I’m trying to run the code here:
http://www.databasedev.co.uk/login.html

Sometime seems to be not quite right. I have a table called ‘tblLogin’ with
the following fields ID, Login, Password, Email, Name, and Level.

I modified the original code slightly, so my code is now:
If Me.txtPassword.Value = DLookup("Login", "tblLogin", _
"[Login]=" & Me.cboEmployee.Value) Then

And, this is where the error occurs.
The message reads: ‘Run-time error: The expression you entered as a query
parameter produced this error ‘brooks’’. This ‘brooks’ is one of the names
in the tblLogin.


My table is named tblLogin,

My ComboBox uses FieldName ‘Login’.

Also, my ComboBox is maned ‘cboEmployee’ and it uses this as the RowSource:
SELECT DISTINCT tblLogin.Login FROM tblLogin ORDER BY tblLogin.Login;


Below is all the code, if it helps; it is mostly like the code on the
site…modified slightly for my data tables and my field names.


It must be something pretty simple; I just don’t see it and this is the
first time I have done such a thing. What am I missing here? Any help would
be greatly appreciated!!

Regards,
Ryan---
 
R

ryguy7272

Oh, I have one more question. Is there a way to get the username from each
user's computer to be the password, or something like that? going to the
'System' and then 'Computer Name' shows the name of the computer (brilliant).
Is there a way to use this as the password, perhaps. Or, can I somehow use
the individual's logon ID? I've done some extensive VBA programming for
Excel and I've done this for a few Excel tools. Does it even make sense to
do such a thing in Access? Is there somethign else, similar but different,
that I can do to generate a bunch of unique, and easy to remember, passwords?

Regards,
Ryan---



--
RyGuy


ryguy7272 said:
These strings tripped me up before, in Excel. Awesome!! Thanks so much!!
Regards,
Ryan---

--
RyGuy


John Spencer said:
I suspect that Login is a text field and that you really want to get the
Password returned by Dlookup. You need to surround the value of CboEmployee
with quote marks so it is treated as a string.

If Me.txtPassword.Value = DLookup("Password", "tblLogin", _
"[Login]=""" & Me.cboEmployee.Value & """") Then

Or use - Note this will error with a name like O'Bryan since Access will think
the string has been terminated after the 0.

If Me.txtPassword.Value = DLookup("Password", "tblLogin", _
"[Login]='" & Me.cboEmployee.Value & "'") Then

Or use

If Me.txtPassword.Value = DLookup("Password", "tblLogin", _
"[Login]=" & chr(34) & Me.cboEmployee.Value & Chr(34)) Then


John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
I’m trying to run the code here:
http://www.databasedev.co.uk/login.html

Sometime seems to be not quite right. I have a table called ‘tblLogin’ with
the following fields ID, Login, Password, Email, Name, and Level.

I modified the original code slightly, so my code is now:
If Me.txtPassword.Value = DLookup("Login", "tblLogin", _
"[Login]=" & Me.cboEmployee.Value) Then

And, this is where the error occurs.
The message reads: ‘Run-time error: The expression you entered as a query
parameter produced this error ‘brooks’’. This ‘brooks’ is one of the names
in the tblLogin.


My table is named tblLogin,

My ComboBox uses FieldName ‘Login’.

Also, my ComboBox is maned ‘cboEmployee’ and it uses this as the RowSource:
SELECT DISTINCT tblLogin.Login FROM tblLogin ORDER BY tblLogin.Login;


Below is all the code, if it helps; it is mostly like the code on the
site…modified slightly for my data tables and my field names.


It must be something pretty simple; I just don’t see it and this is the
first time I have done such a thing. What am I missing here? Any help would
be greatly appreciated!!

Regards,
Ryan---
 
R

ryguy7272

I just had another idea. I've never worked with security features for Access
before now, but would it make sense to pass a parameter, such as this
variable:
"[Login]="""

I was thinking of passing the variable to the UserForm that opens, when the
user ID and password are verified, and set up something like:

User: TextBox

The user’s ID would appear in the textbox and then that individual could
create reports and queries that pertain specifically to them? Does it make
sense to set it up this way? How could I pass that value to a TextBox on the
UserFrom that opens when all information is verified? the TextBox would
somehow have to equal [Login]...I guess... If anyone has any ideas about
this, or the last issue (getting the UserName from the system), please post
back.

Regards,
Ryan--

--
RyGuy


ryguy7272 said:
Oh, I have one more question. Is there a way to get the username from each
user's computer to be the password, or something like that? going to the
'System' and then 'Computer Name' shows the name of the computer (brilliant).
Is there a way to use this as the password, perhaps. Or, can I somehow use
the individual's logon ID? I've done some extensive VBA programming for
Excel and I've done this for a few Excel tools. Does it even make sense to
do such a thing in Access? Is there somethign else, similar but different,
that I can do to generate a bunch of unique, and easy to remember, passwords?

Regards,
Ryan---



--
RyGuy


ryguy7272 said:
These strings tripped me up before, in Excel. Awesome!! Thanks so much!!
Regards,
Ryan---

--
RyGuy


John Spencer said:
I suspect that Login is a text field and that you really want to get the
Password returned by Dlookup. You need to surround the value of CboEmployee
with quote marks so it is treated as a string.

If Me.txtPassword.Value = DLookup("Password", "tblLogin", _
"[Login]=""" & Me.cboEmployee.Value & """") Then

Or use - Note this will error with a name like O'Bryan since Access will think
the string has been terminated after the 0.

If Me.txtPassword.Value = DLookup("Password", "tblLogin", _
"[Login]='" & Me.cboEmployee.Value & "'") Then

Or use

If Me.txtPassword.Value = DLookup("Password", "tblLogin", _
"[Login]=" & chr(34) & Me.cboEmployee.Value & Chr(34)) Then


John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County

ryguy7272 wrote:
I’m trying to run the code here:
http://www.databasedev.co.uk/login.html

Sometime seems to be not quite right. I have a table called ‘tblLogin’ with
the following fields ID, Login, Password, Email, Name, and Level.

I modified the original code slightly, so my code is now:
If Me.txtPassword.Value = DLookup("Login", "tblLogin", _
"[Login]=" & Me.cboEmployee.Value) Then

And, this is where the error occurs.
The message reads: ‘Run-time error: The expression you entered as a query
parameter produced this error ‘brooks’’. This ‘brooks’ is one of the names
in the tblLogin.


My table is named tblLogin,

My ComboBox uses FieldName ‘Login’.

Also, my ComboBox is maned ‘cboEmployee’ and it uses this as the RowSource:
SELECT DISTINCT tblLogin.Login FROM tblLogin ORDER BY tblLogin.Login;


Below is all the code, if it helps; it is mostly like the code on the
site…modified slightly for my data tables and my field names.


It must be something pretty simple; I just don’t see it and this is the
first time I have done such a thing. What am I missing here? Any help would
be greatly appreciated!!

Regards,
Ryan---
 

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