count current users

AstonCheah

Registered User.
Local time
Today, 22:46
Joined
Jul 31, 2008
Messages
23
can we know how many users are accessing a database in the same time in vba? something like count(currentuser)...
 
Not quite that easy. The lock file is actually a database format file you could read (* in read-only mode) that might give you some hints as to who is there right now. But no guarantees.

I usually did this another way, though it was still clunky. I included an audit log via my startup form. The startup form wrote a record "User XYZ entering at dd-mmm-yyyy hh:nn:ss" when it loaded and another record "User XYZ exiting at dd-mmm-yyyy hh:nn:ss" when it closed. Then I just looked for "Enter" without corresponding "Exit". I also made it a sliding window of only entries for the last 24 hours, so that I wouldn't have to go through a raft of properly paired enter/exit records for the last two months or so. That worked most of the time except after a network disaster. (Which is why I limited things to 24 hours.)

The catch is that the Startup form cannot go away. You just minimize it and make it invisible. Then when the user tries to exit, the form closes, visible or not.
 
Here's a sample that basically does what The_Doc_Man said.

In the sample it isn't set to hide the form on open but it would in real life.
 

Attachments

Users who are viewing this thread

Back
Top Bottom