kick users off shared database

G

Guest

I came across this code and am trying to use it for my database. Is a small
database that will track the process of moving code through the SDLC process.
Each time there is movement to testing an approval is warranted. There may
be up to 20 or so people using this database at the same time and if I run
into problems and need exclusive rights, I would like to be able to
"kickemoff". Here is the code that I am using.

Function fGetOut() As Integer
Dim RetVal As Integer
Dim db As DAO.Database

Dim rst As Recordset
On Error GoTo Err_fGGO
Set db = DBEngine.Workspaces(0).Databases(0)
Set rst = db.OpenRecordset("KickEmOff", dbOpenSnapshot)
If rst.EOF And rst.BOF Then
RetVal = True
GoTo Exit_fGGO
Else
If rst!GetOut = True Then
'This is where you close down any forms, and quit the database
'I leave this section as an exercise in creativity
Application.Quit
Else
RetVal = True
End If
End If
Exit_fGGO:
fGetOut = RetVal
Exit Function
Err_fGGO:
'Note lack of message box on error
Resume Next
End Function

This is in a module and there is a form that I am told that if I click the
box and hit enter, all users should be knocked out of the database. Is there
something that I need to add here. I am getting no error messages, yet the
users are still on when I use the form.
 
G

Guest

This code checks a value in a table to see if the user should be kicked out.
If it's true, it will quit the app. The trick is that you need to run this
code on the client's machine periodically by using a timer. If you have some
sort of menu/switchboard that cannot be closed, you can use its timer,
otherwise I suggest a sentry form that you open hidden when the app opens and
put the timer there. In the form's OnTimer event, put your code and set the
timer to something like 60000 (one minute), so you're not deluging the
database with too many reads.

The comment in the code that suggests an "exercise in creativity" is
important. If you just quit the app, users will lose any pending work. You
might want to put a messagebox in front of the quit statement that allows the
user to defer the quit for a minute.

Barry
 
G

Guest

Barry:

I have set up a sentry form that is hidden and that is opened when the
switchboard is opened and it remains hidden. I have put the code in the
timer and have put a message box to alert the users that they will be logged
off. I assume that by using the "Kick Em Off" form, checking the "Get Off"
box and hitting enter that the code should run from there. I get no error
messages, but nothing happens. I don't get my message box. What could I be
doing wrong? Do I need to change the code in some way.

Rob
 

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