Who's got the database open?

B

B. Meincke

I have the following subroutine attached to the OnOpen method of our database
switchboard:

Dim fs, f, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.getfile("\\servername\rest of path\database name.ldb")
s = UCase(f.Name) & " uses " & f.Size & " bytes."

If f.Size = 64 Then
Exit Sub

Else
MsgBox "The database is in use. Please try again later.", _
vbExclamation, "Sorry..."
mcrQuit 'this is the name of a function in a module

End If

Set f = Nothing
Set fs = Nothing

Please, without passing judgement about how it would be more efficient to
split the thing, which I intend to do over the summer break, but until
then... for obvious reasons, it is important to disallow multiple users
accessing it at once. The above code works, but...

Is there any way I can include the domain username of the person logged onto
the workstation on which the database is already open in the message box
text? This would really help track down folks who forget and leave it open!

I already have a module that reads the domain username and the domain name
that I use for other things. Can I somehow utilize the GetUser function for
this task?

As always, thank you in advance for any suggestions.
 

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