473,387 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Check for user name already in secure database

Hello all...

I am using Access 2002. I have database set to add users names to the
user level security when they are added to a particular table in a
database, using the Catalog and ActiveConnection commands. I am
getting errors when I try to add a name that is already in the
database. I was wondering if anyone knew of a way to have it check
for the user's name before going to add it? One method would be to
delete everytime before adding, but that seems like it would cause
problems as well.

Thanks in advance,
Therese
Nov 12 '05 #1
9 2411
Can you not simply field the error using On Error GoTo ... and an
error-handling routine? If not, please be specific about the error, and the
exact circumstances under which you are getting it and perhaps someone will
have suggestions.

It is often much simpler to just deal with an error rather than trying to
avoid it.

Larry Linson
Microsoft Access MVP

"Therese A. Sorna" <ta*****@yahoo.com> wrote in message
news:be**************************@posting.google.c om...
Hello all...

I am using Access 2002. I have database set to add users names to the
user level security when they are added to a particular table in a
database, using the Catalog and ActiveConnection commands. I am
getting errors when I try to add a name that is already in the
database. I was wondering if anyone knew of a way to have it check
for the user's name before going to add it? One method would be to
delete everytime before adding, but that seems like it would cause
problems as well.

Thanks in advance,
Therese

Nov 12 '05 #2

"Therese A. Sorna" <ta*****@yahoo.com> wrote in message
news:be**************************@posting.google.c om...
Hello all...

I am using Access 2002. I have database set to add users names to the
user level security when they are added to a particular table in a
database, using the Catalog and ActiveConnection commands. I am
getting errors when I try to add a name that is already in the
database. I was wondering if anyone knew of a way to have it check
for the user's name before going to add it? One method would be to
delete everytime before adding, but that seems like it would cause
problems as well.

Thanks in advance,
Therese

Best place to get answers is at the official MVP site:
http://mvp.org
Dorothy Moody MVP
Nov 12 '05 #3

"Dorothy Moody" <s2******@aol.com> wrote in message
news:fc******************************@news.teranew s.com...


Best place to get answers is at the official MVP site:
http://mvp.org
Dorothy Moody MVP


NOT!!!
Nov 12 '05 #4
TC
"Therese A. Sorna" <ta*****@yahoo.com> wrote in message
news:be**************************@posting.google.c om...
Hello all...

I am using Access 2002. I have database set to add users names to the
user level security when they are added to a particular table in a
database, using the Catalog and ActiveConnection commands. I am
getting errors when I try to add a name that is already in the
database. I was wondering if anyone knew of a way to have it check
for the user's name before going to add it?
No idea with ADO. But with DAO:

dim s as string
on error resume next
s = dbengine(0).users("Fred").name
if err.number <> 0 then s = ""
on error goto 0

if s = "" then
' user not defined.
else
' user is defined.
endif

One method would be to delete everytime before adding,
but that seems like it would cause problems as well.


Gak! Don't do that. It would be doomed to failure unless you used the exact
same PID value that was used when the user was created originally. And you
can not get the PID from Access or Jet (so you'd have to get it by some
other means). I do mean PID, not user-level password.

HTH,
TC

Nov 12 '05 #5
The code worked great with minor changes (DAO vs ADO). Basically just
replaced the dbengine(0) with cat, and off I was! The key was the 'on
error resume next'.

Thanks!
T

"TC" <a@b.c.d> wrote in message news:<1066802883.653492@teuthos>...
"Therese A. Sorna" <ta*****@yahoo.com> wrote in message
news:be**************************@posting.google.c om...
Hello all...

I am using Access 2002. I have database set to add users names to the
user level security when they are added to a particular table in a
database, using the Catalog and ActiveConnection commands. I am
getting errors when I try to add a name that is already in the
database. I was wondering if anyone knew of a way to have it check
for the user's name before going to add it?


No idea with ADO. But with DAO:

dim s as string
on error resume next
s = dbengine(0).users("Fred").name
if err.number <> 0 then s = ""
on error goto 0

if s = "" then
' user not defined.
else
' user is defined.
endif

One method would be to delete everytime before adding,
but that seems like it would cause problems as well.


Gak! Don't do that. It would be doomed to failure unless you used the exact
same PID value that was used when the user was created originally. And you
can not get the PID from Access or Jet (so you'd have to get it by some
other means). I do mean PID, not user-level password.

HTH,
TC

Nov 12 '05 #6
It would make for better code if you did deal with cause rather than just
trap the error (even if it's not simpler) :)

You can loop through all the users and try to find a match first before
adding one. If you need sample code let me know.
--
Bradley
Software Developer www.hrsystems.com.au
A Christian Response www.pastornet.net.au/response

"Larry Linson" <bo*****@localhost.not> wrote in message
news:RE******************@nwrddc01.gnilink.net...
Can you not simply field the error using On Error GoTo ... and an
error-handling routine? If not, please be specific about the error, and the exact circumstances under which you are getting it and perhaps someone will have suggestions.

It is often much simpler to just deal with an error rather than trying to
avoid it.

Larry Linson
Microsoft Access MVP

"Therese A. Sorna" <ta*****@yahoo.com> wrote in message
news:be**************************@posting.google.c om...
Hello all...

I am using Access 2002. I have database set to add users names to the
user level security when they are added to a particular table in a
database, using the Catalog and ActiveConnection commands. I am
getting errors when I try to add a name that is already in the
database. I was wondering if anyone knew of a way to have it check
for the user's name before going to add it? One method would be to
delete everytime before adding, but that seems like it would cause
problems as well.

Thanks in advance,
Therese


Nov 12 '05 #7
Sure, I would much rather do that than to trap an error. Please
provide sample code.

T

"Bradley" <br*****@REMOVETHIScomcen.com.au> wrote in message news:<3f******@nexus.comcen.com.au>...
It would make for better code if you did deal with cause rather than just
trap the error (even if it's not simpler) :)

You can loop through all the users and try to find a match first before
adding one. If you need sample code let me know.
--
Bradley
Software Developer www.hrsystems.com.au
A Christian Response www.pastornet.net.au/response

"Larry Linson" <bo*****@localhost.not> wrote in message
news:RE******************@nwrddc01.gnilink.net...
Can you not simply field the error using On Error GoTo ... and an
error-handling routine? If not, please be specific about the error, and

the
exact circumstances under which you are getting it and perhaps someone

will
have suggestions.

It is often much simpler to just deal with an error rather than trying to
avoid it.

Larry Linson
Microsoft Access MVP

"Therese A. Sorna" <ta*****@yahoo.com> wrote in message
news:be**************************@posting.google.c om...
Hello all...

I am using Access 2002. I have database set to add users names to the
user level security when they are added to a particular table in a
database, using the Catalog and ActiveConnection commands. I am
getting errors when I try to add a name that is already in the
database. I was wondering if anyone knew of a way to have it check
for the user's name before going to add it? One method would be to
delete everytime before adding, but that seems like it would cause
problems as well.

Thanks in advance,
Therese


Nov 12 '05 #8
"Better" code _how_, Bradley? Esthetically more pleasing? Less work for the
developer? Less work for the user?

Often, when you have the capability of trapping an error and dealing with
it, that is the most direct, simplest, and easiest approach, and the user
never knows that you didn't "avoid" it... it's not like you actually add a
duplicate and the user stumbles over it later.

It'd be something like testing for the error number in your error handling,
giving the user a MsgBox (same as you would in an avoidance situation)
saying "duplicate name, please change", and returning to the input screen
(same as you would in an avoidance situation).

What you _don't_ have to do is have code to run through a hierarchy of
containers, collections, and properties to be able to determine that you
need to give the user that very same MsgBox and return to that very same
form.

I really do not understand how you define "more work", "more code", and
"more resources used" to accomplish exactly the same result as "better
code".

Larry Linson
Microsoft Access MVP

"Bradley" <br*****@REMOVETHIScomcen.com.au> wrote in message
news:3f******@nexus.comcen.com.au...
It would make for better code if you did deal with cause rather than just
trap the error (even if it's not simpler) :)

You can loop through all the users and try to find a match first before
adding one. If you need sample code let me know.
--
Bradley
Software Developer www.hrsystems.com.au
A Christian Response www.pastornet.net.au/response

"Larry Linson" <bo*****@localhost.not> wrote in message
news:RE******************@nwrddc01.gnilink.net...
Can you not simply field the error using On Error GoTo ... and an
error-handling routine? If not, please be specific about the error, and

the
exact circumstances under which you are getting it and perhaps someone

will
have suggestions.

It is often much simpler to just deal with an error rather than trying to avoid it.

Larry Linson
Microsoft Access MVP

"Therese A. Sorna" <ta*****@yahoo.com> wrote in message
news:be**************************@posting.google.c om...
Hello all...

I am using Access 2002. I have database set to add users names to the
user level security when they are added to a particular table in a
database, using the Catalog and ActiveConnection commands. I am
getting errors when I try to add a name that is already in the
database. I was wondering if anyone knew of a way to have it check
for the user's name before going to add it? One method would be to
delete everytime before adding, but that seems like it would cause
problems as well.

Thanks in advance,
Therese



Nov 12 '05 #9
TC

"Bradley" <br*****@REMOVETHIScomcen.com.au> wrote in message
news:3f******@nexus.comcen.com.au...
It would make for better code if you did deal with cause rather than just
trap the error (even if it's not simpler) :)

You can loop through all the users and try to find a match first before
adding one. If you need sample code let me know.

Nonsense. Why loop through 'x' number of users, when a single statement
(preceded by an On Error) will do exactly what he wants?

If you need to see whether a certain value exists for an indexed field in a
table, do you loop through every record in the table, looking for that
value? Nope. You try to find the value in question, & trap the error if it
aint there.

Same case here.

TC

Nov 12 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
by: mrbog | last post by:
Tell me if my assertion is wrong here: The only way to prevent session hijacking is to NEVER store authentication information (such as name/password) in the session. Well, to never authenticate...
6
by: joethis | last post by:
Is there a way to make sure that a file is already in use using asp? For instance, if one person has opened a file and is about to write to it; then is there a way to keep another user from...
29
by: Lauren Wilson | last post by:
Does anyone know how the following info is extracted from the user's computer by a Front Page form? HTTP User Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107...
3
by: MLH | last post by:
I was running the following code while logged in as a user belonging only to the Users group. Set usrNew = .CreateUser(Me!UserID) 'The user ID is in a control on the form usrNew.PID =...
4
by: shapper | last post by:
Hello, I am creating a Poll system and I need to check if a user has already voted. What should be the best way to do this? 1. Should I save the user IP along with its vote in the database?...
9
by: webrod | last post by:
Hi all, how can I check a user/password in a LDAP ? I don't want to connect with this user, I would like to connect to LDAP with a ADMIN_LOG/ADMIN_PWD, then do a query to find the user and...
2
by: Earl | last post by:
Is there any sort of check that can be done to see if a particular instance of SQL Server is present? I already call a method to check for connection -- if no connection, I have the user re-enter...
4
by: mrouleau | last post by:
I am sorry if this is the wrong group to ask, if so please point me in the correct direction. My problem is I have an MDB file with user-level security on it (mdw). When i move it over to a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.