Matching a value from a form, in a table

D

Darren

Hi. I am hoping someone can help me, with what may be a basic question.

I have a table which contains 2 fields - passwords and access levels. I
want to create a password login form, which then checks the entered password
against the table. If it matches a password in the table, I need to return
the access level value from that record, back to the form. I am unsure of the
code I need to use to check the table for a match to the entered password,
and the return another value back to the form.

If anyone could help me, I would be very grateful.

Thanks in advance,

Darren
 
D

Douglas J. Steele

Hopefully you're not doing this because you hope it'll provide security,
because it won't.

You can use the DLookup function to return the access level:

strAccessLevel = DLookup("[AccessLevel]", "[MyTable]", _
"[Password] = " & Chr$(34) & strPassword & Chr$(34))

If you want to have case sensitivity for the passwords, try:

strAccessLevel = DLookup("[AccessLevel]", "[MyTable]", _
"StrComp([Password], " & _
Chr$(34) & strPassword & Chr$(34) & ", 0) = 0")
 
D

Darren

Thanks Douglas,

I am wanting to do it so a I can have various buttons and features
available, depending on access level. It is also so, for example one person
can edit one forms data, but only view another. I also need the "main user"
of the file to be able to change passwords easily, for the lower levels of
access.

Should I be doing this another way? I have heard of user level security, but
thought that was more of an all or nothing security, and it wouldnt allow me
to fine tune the forms as much. Maybe I could use that, and use the username
value?

Thanks for any further help,

Darren

Douglas J. Steele said:
Hopefully you're not doing this because you hope it'll provide security,
because it won't.

You can use the DLookup function to return the access level:

strAccessLevel = DLookup("[AccessLevel]", "[MyTable]", _
"[Password] = " & Chr$(34) & strPassword & Chr$(34))

If you want to have case sensitivity for the passwords, try:

strAccessLevel = DLookup("[AccessLevel]", "[MyTable]", _
"StrComp([Password], " & _
Chr$(34) & strPassword & Chr$(34) & ", 0) = 0")



--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Darren said:
Hi. I am hoping someone can help me, with what may be a basic question.

I have a table which contains 2 fields - passwords and access levels. I
want to create a password login form, which then checks the entered
password
against the table. If it matches a password in the table, I need to return
the access level value from that record, back to the form. I am unsure of
the
code I need to use to check the table for a match to the entered password,
and the return another value back to the form.

If anyone could help me, I would be very grateful.

Thanks in advance,

Darren
 
D

Douglas J. Steele

While your approach will let you pick what features to display, all a user
needs to do is open the table and change the password or access level
information. Remember, they'll be able to link to your application from
outside of it, so setting the AllowByPassKey property and hiding the
database window isn't going to give you any protection at all.

Security isn't an all-or-nothing proposition. Rather, users are assigned to
groups, and groups can have varying permissions.

To get started with security, read
http://support.microsoft.com/support/access/content/secfaq.asp thoroughly
several times. Always work on a copy of your database, and make sure you
don't leave any steps out.

There's a newsgroup devoted to Access security as well:
microsoft.public.access.security if you have additional questions.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Darren said:
Thanks Douglas,

I am wanting to do it so a I can have various buttons and features
available, depending on access level. It is also so, for example one
person
can edit one forms data, but only view another. I also need the "main
user"
of the file to be able to change passwords easily, for the lower levels of
access.

Should I be doing this another way? I have heard of user level security,
but
thought that was more of an all or nothing security, and it wouldnt allow
me
to fine tune the forms as much. Maybe I could use that, and use the
username
value?

Thanks for any further help,

Darren

Douglas J. Steele said:
Hopefully you're not doing this because you hope it'll provide security,
because it won't.

You can use the DLookup function to return the access level:

strAccessLevel = DLookup("[AccessLevel]", "[MyTable]", _
"[Password] = " & Chr$(34) & strPassword & Chr$(34))

If you want to have case sensitivity for the passwords, try:

strAccessLevel = DLookup("[AccessLevel]", "[MyTable]", _
"StrComp([Password], " & _
Chr$(34) & strPassword & Chr$(34) & ", 0) = 0")



--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Darren said:
Hi. I am hoping someone can help me, with what may be a basic question.

I have a table which contains 2 fields - passwords and access levels.
I
want to create a password login form, which then checks the entered
password
against the table. If it matches a password in the table, I need to
return
the access level value from that record, back to the form. I am unsure
of
the
code I need to use to check the table for a match to the entered
password,
and the return another value back to the form.

If anyone could help me, I would be very grateful.

Thanks in advance,

Darren
 

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