How to open the .ldb file and use the info within, current users?

G

Guest

Does anybody have some sample code to allow me to open the .ldb file of the
current database running the code. I am running ACCESS 2000, and using ADO on
a local database stored on a network shared drive.

I need to view a list of the current users logged into the database from the
currently open database. The intention is to allow only one user to use the
database at a time. If I have the users open it exclusively, when another
user tries to log on it displays "W:\xxx\xxx\database.mdb is already in use".
I would like to open the .ldb file (or poll otherwise) the users, if there is
a current user then display "user: xxxx has the database open. Pleae try
again soon". That way the 2nd user can inquire the 1st if they are using the
database too long.

I tried the USER_ROSTER method but could not get it to work on the
currently open database.

Thanks for your help in advance.
 
K

Keith Wilby

Mac said:
Does anybody have some sample code to allow me to open the .ldb file of
the
current database running the code. I am running ACCESS 2000, and using ADO
on
a local database stored on a network shared drive.

I need to view a list of the current users logged into the database from
the
currently open database. The intention is to allow only one user to use
the
database at a time. If I have the users open it exclusively, when another
user tries to log on it displays "W:\xxx\xxx\database.mdb is already in
use".
I would like to open the .ldb file (or poll otherwise) the users, if there
is
a current user then display "user: xxxx has the database open. Pleae try
again soon". That way the 2nd user can inquire the 1st if they are using
the
database too long.

I tried the USER_ROSTER method but could not get it to work on the
currently open database.

Thanks for your help in advance.

I have a question: why do you want to use a multi-user application in an
exclusive mode? In answer to your question it would probably be easier and
more reliable to use the network logon in a lookup table. When a user logs
on, store their network ID in a table. When a second user logs on, do a
DLookup on the table and quit if there is a record there, using the stored
ID in a message box if you like. Delete the user from the lookup table when
they quit the app.

HTH - Keith.
www.keithwilby.com
 
G

Guest

I would log their network logon if I knew how to access it. That is my point.
I have tried "currentUser" property but that only gives me one name. I have
tried USER_ROSTER but keep getting errors and it won't return a list of the
users. How do I get the network logon? My next attempt was to open and view
the .ldb file.

And to answer your question "Why use a multi-user application in exclusive
mode?". Due to it's design I can only have one person use the database at a
time. It is a reservation database and it does not live update the available
items. Due to that limitation only one person can logon, view available
items, reserve them, and then exit. Once the next person opens the database
the reserved items are no longer available to them that the first person
reserved. Opening it in exclusive mode was an attempt to block the second
person from opening the database. I am looking, as you can tell, for a more
elegant method of allowing only one person to access the db at a time.

I need a method to allow one person to have the database open, when another
attempts to logon it displays a warning telling them whos is logged on, and
then exits. Do you have more detail on how to return the current users of an
Access db?
 
K

Keith Wilby

Hi Michael ...

Mac said:
How do I get the network logon?

' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If (lngX > 0) Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function

' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Function fOSMachineName() As String
'Returns the computername
Dim lngLen As Long, lngX As Long
Dim strCompName As String
lngLen = 16
strCompName = String$(lngLen, 0)
lngX = apiGetComputerName(strCompName, lngLen)
If lngX <> 0 Then
fOSMachineName = Left$(strCompName, lngLen)
Else
fOSMachineName = ""
End If
End Function
And to answer your question "Why use a multi-user application in exclusive
mode?". Due to it's design I can only have one person use the database at
a
time. It is a reservation database and it does not live update the
available
items. Due to that limitation only one person can logon, view available
items, reserve them, and then exit. Once the next person opens the
database
the reserved items are no longer available to them that the first person
reserved. Opening it in exclusive mode was an attempt to block the second
person from opening the database. I am looking, as you can tell, for a
more
elegant method of allowing only one person to access the db at a time.

I need a method to allow one person to have the database open, when
another
attempts to logon it displays a warning telling them whos is logged on,
and
then exits. Do you have more detail on how to return the current users of
an
Access db?

I'm not sure what you mean by "live update". Is you application split into
front/back ends?

Regards,
Keith.
 

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