multi user - login at exactly the same time

NOL

Registered User.
Local time
Today, 16:20
Joined
Jul 8, 2002
Messages
102
Hi,
I have a multiuser Access database.
The login form has a dropdown displaying the names of all users.
and any1 can login as any1 from different machines.

I've created a table USER_LOG, which records the Network login name and computer name when a person logs in. ( thanks to all the big brains on this forum !! )

Before any1 logs in i check this table to see if user is already logged in. if yes it displays a message saying "u are already logged in as <user name>"

MY PROBLEM:
As a test , i and a friend logged into the system from diff PCs at the Exact moment ,as the same user . and my logic doesn't work.
both can get in .

i'm assuming this is beacuse , two people are trying to write to my table uSeR_LOG at the same time ?

Is there any way out of this ?
Thanks,
Gina.

PS: pls let me know if i haven't been clear enuf.
 
If I understand, you log the user in a table, and do not allow them to login of you find that user name in your table.
If the name is not there, it lets them log in, hence the same user logging in at the same time is a timing function. Both check the table, the logged in name is not there, they both log in. One thing you could do is check when you are inserting the login to verify it is not there. That would cut down the checking time if you are going through to much code. Create a unique index on login name that would cause an error if duplicate entries were inserted (forcing an error).
Question: What happens when Bob logs in, System crashes, he reboots and tries to log in again and can't because it thinks he is logged in already?
Enquiring minds want to know?
 
Hi ,

Thanks ! You understood perfectly! :-)

But I didn't quite understand the solution you suggested.

Quote :
"One thing you could do is check when you are inserting the login to verify it is not there. That would cut down the checking time if you are going through to much code."

I am using dbs.openrecordset and , rs.recordcount<>0 to check existence of the record. And i do this check when user cliks on a button, after entering his login name

The create index part makes a lot of sense , I'll try that . no matter what the timing it wldn't allow duplicates anyway !


About ur question ( in case of system crash) , i didn't even think about that !!! what cld one possibly do ??
it needs a lil more thinking on my part , if u do have suggestions please let me know .

Thanks a lot ,
Gina
 
I'm stumped !

I defined teh field 'User' in 'USER_LOG'
as the Primary key ( index : Yes(no duplicates)

If i open the table and add a primary key 'abc' that already exists it throws the expected error and does not allow the table to be updated

However If i do the same using teh foll code in the on_load event of a form , it does not throw any error ( of course it does not update either)

Dim dbs as datanbase
dbs.Execute Insert into USER_LOG Values ( 'abc')

I was hoping to capture the error number .
I can't see what I'm doing to prevent the error from showing up .
 
To catch the error on this is the syntax something like
Variable = dbs.Execute "Insert into USER_LOG Values ( 'abc')"
and the Return value of the execute will be in Variable?
Or something along those lines I think
 
dbs.Execute does not return any value. What you can do is using the option dbSeeChanges with dbs.Execute which will raise an error if another user tries changing the data you're just writing.
 
here is an other suggestion.
Code:
If Not IsNull(DLookup("User", "USER_LOG", "User='" & Me!YourDropDown & "'")) Then
  Beep
  MsgBox Me!YourDropDown & " is already connected.", vbOKOnly, "Login Fault!"
Else
  dbs.Execute ...
End If
 
Thanks Nouba , appreciate your help.

I've tried this method and it does work perfectly well.

Except that i am looking to throw the error instantly, without time delays.
if a user tries to write to the table Access won't allow it due to duplicate primar key and that's what i want to capture.


Gina.
 

Users who are viewing this thread

Back
Top Bottom