Identify & Message Logged In Users

Duncs

New member
Local time
Today, 18:38
Joined
Oct 15, 2009
Messages
6
I have an Access db, FE/BE, and I sometime need to update the BE data, or get them to use the latest version of the FE. What I’m looking for, is a way to identify users logged iinto the database and then either send them a message from the database—or another one—to get them to log out. It would also be beneficial if I could somehow "kick them out" of the database, as users have been known to leave the PC switched on and go home, with the application still loaded, or just switch off the PC without logging out.

Possible?
 
In principle this is a case of training and not a programming resolve. However if you are the network admin person you should be able to remote disconnect users from the network. However, if not, then take a look at this demo this will identify who is actuially logged in at the present moment in time.

David
 
David,

I agree that it is a "training" issue, but I think I would have a better chance with a room full of Monkeys! :rolleyes:

I've downloaded the file you provided but I have a small problem with it. The BE of the database is password protected, to prevent users from accessing / modifying the data directly. As a result, when I try to view the connections I get the error:

Run-time error '-2147217843 (80040e4d)':
Not a valid password

When I enter debug mode, it gives me this line highlighted:

.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Me.TxtPath & "\" & Me.TxtFile

I tried adding the DB password after the Me.TxtFile as follows:

.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Me.TxtPath & "\" & Me.TxtFile, , & _
password

But this didn't help. Can you advise?

TIA

Duncs
 
Do not have access to the correct code until tomorrow. But try opening a none password protected database to test the functionality to see it is suits your needs.

David
 
David,

It works great. It does however show my details twice, when I use it against the 'CurrentUsers' database, which I currently have open.

The option to lock the database is great and is something that I can certainly use. The 'Disconnect User' and 'Send Message' functions would be great as well however, as you have said, these are still under development.

When I test it against a DB with two users in it, I get the following error:

Run-time error '3251';

Object or provider is not capable of performing requested operation.


Debug gives the line in error as:

' The user roster is exposed as a provider-specific schema rowset
' in the Jet 4.0 OLE DB provider. You have to use a GUID to
' reference the schema, as provider-specific schemas are not
' listed in ADO's type library for schema rowsets

Set rs = cn.OpenSchema(adSchemaProviderSpecific, _
, "{947bb102-5d43-11d1-bdbf-00c04fb92675}")

I don't know if it's something I'm doing / have done. I'm using Access 2003, in case that makes a difference.

Many thanks for your help with this.

Duncs
 
I have a similar setup for a database I have disigned at work. The way I resolve it is fairly easy

1. I open a hidden form with a timer that fires every 30 seconds and queries a value (that i can set on or off) in a lookup table. If I need to update the database, I set this value to true.

2. If the value is true then the timer function on my hidden form displays a timed message box to the user warning that the program will exit in 30 sec., and then closes the program after a wait.

3. I have written a function which I run when I need to do updates which (1) sets my lookup value, (2) executes a Do ...Loop which looks for the existence of the locking file for the backend (which will disappear when all users have logged out), (3) performs updates and (4) resets the lookup value which allows users to log back in. When the program starts it first examines the lookup value and if it's set to true during an update, then the user is given a message and immediately logged back out. It took me while to get it all in place, but has been working very well for me for the last year or so.
 
I appreciate it might be a bit cheeky but...any chance you could share your code?
 
Bare bones version, but this should get you started ...
Code:
Public Function CheckStatus()
' Use this in the OnOpen Event of your main form, switchboard form, etc ... or in the Main sub that runs whenever your user first open their Front End
  Dim blnUnderDev As Boolean
  Dim rst         As DAO.Recordset
  
  On Error GoTo ERR_HANDLER
10:    Set rst = CurrentDb.OpenRecordset("tblDev") 'Lookup table
   
20:    With rst
30:      .FindFirst "[ID] = 1"
40:      blnUnderDev = ![UnderDev] 'True if I have set the flag
50:      .Close
60:    End With
   
70:    Set rst = Nothing
   
80:    If blnUnderDev = True Then
90:      MsgBox "The Database is currently down for modification or repair", vbOKOnly, "Administrator Message"
100:     Application.Quit
110:   Else
         'Continue
120:   End If
   
130:   Exit Function
ERR_HANDLER:
140:   SendError "#" & Err.Number & ": " & Err.Description, "CheckStatus", CStr(Erl)
   
End Function
   
Public Function CheckStatusOpen()
'This code fires at the OnTimer event of a hidden form that opens when the program starts and stays open in the background
       
  Dim blnUnderDev As Boolean
10:    blnUnderDev = DLookup("[UnderDev]", "tblDev", "[ID] = 1")
   
20:    If blnUnderDev = True Then
         'Open a borderless message form with a 30 second timer that informs the user that updates need to be made and warns of a shutdown in 30 sec
30:      DoCmd.openForm "frmAdminMsg"
40:    End If
   
End Function
   
Public Function getOut()
'This code fires at the OnTimer event of my "frmAdminMsg" form
       
  On Error Resume Next
   
10:    DoCmd.Close acForm, "frmHidden"
20:    DoCmd.Close acForm, "frmAdminMsg"
30:    Application.Quit
 
40:    Exit Function
ERR_HANDLER:
50:    SendError "#" & Err.Number & ": " & Err.Description, "getOut", CStr(Erl)
End Function
 
Public Function modify()
'This code goes in my development database and I run it when I need to make updates
  
  Dim strLdbName As String
  
  On Error GoTo ERR_HANDLER
10:    strLdbName = "Z" 'Put the pathname to your locking file here instead of "Z"
20:    CurrentDb.Execute "UPDATE tblDev SET tblDev.UnderDev = True WHERE (((tblDev.ID)=1))" 'Set my development flag in the lookup table which is a linked table in my development databse - the lookup table resides in the BackEnd database
      
      'This loop runs until the locking file is gone, indicating all users are out of the backend
30:    Do
40:      strTest = Dir(strLdbName, vbHidden)
50:      DoEvents
60:    Loop Until strTest = ""
   
70:    Sleep 6000 'I had to put this here as a delay.  I was having some problems with doing updates immediately - don't quite know why
       'Insert code to do your updates here
       
       'Reset the development flag in the lookup table to "off", allowing users to open the FrontEnd again
80:    CurrentDb.Execute "UPDATE tblDev SET tblDev.UnderDev = False WHERE (((tblDev.ID)=1))"
 
90:    Exit Function
ERR_HANDLER:
100:   SendError "#" & Err.Number & ": " & Err.Description, "Modify", CStr(Erl)
End Function
 
Fantastic!! :)

With a little modification to suit my tables etc., it works a treat.

Once again, my many thanks!!
 
In principle this is a case of training and not a programming resolve. However if you are the network admin person you should be able to remote disconnect users from the network. However, if not, then take a look at this demo this will identify who is actuially logged in at the present moment in time.

David

David I have downloaded the db and run it on my pc (access 2007 - windows 7)
but i got the following error message:

....missing or broken reference to the file 'COMDLG32.OCX' version 1.2

There is a MISSING Microsoft common dialog box control reference in the reference window. (I clear that...)

also runtime error (438) object does not support this property or method

and please for password protected database how it could be possible?

I wrote a function to send messages right from the administrator panel to all or specific user and can chat with them as well using my application, also can see the logged in users in the list,their logged in and log out times, user names, machine names etc, moreover I can kick them out from the application whenever it is needed.

Moreover a function for idol users will trigged and the application will close automatically if it is not used for 20 minutes....

I also developed an auto update new version function which will install/copy the new version to user's desktops whenever a new version is ready to deploy.


I want to test your code also, but got these errors.

can you guide me to run your code plz.

Thanks
Khalid
 

Users who are viewing this thread

Back
Top Bottom