Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there any way if I can detect that another Access front end is open from my front end? 1

Status
Not open for further replies.

weightinwildcat

Programmer
May 11, 2010
84
US
Is there any way if I can detect that another Access front end is open from my front end?
 
I believe you'd have to set that logging up ahead of time. However, if you know the location of the other front-end, then you could use the FileSystemObject in VBA to check for the lock file. The best option, to my knowledge, is to setup logging so that as soon as the front-end is opened, it creates a record in the back-end log table. And to my knowledge, when I say logging, I mean create a table that will be the log table, then use VBA or an Access macro to write the the log entry upon opening the form (Form_Open event). And that, I'd do, as either a SQL string or an Access query executed by the VBA/Macro.

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
Sorry...don't have time to work on this, right now...but as an approach, you could have a Table in your Back End where users are 'signed-in' when they open their Front ends, and 'signed-out,' when they close it, and then a Form to show who is signed in, at a given time, based on this Table.

The Missinglinq

Richmond, Virginia

The Devil's in the Details!
 
Logging in/out doesn't work when error exiting - unless you include extensive error reporting in ALL of your code (every procedure / module). Even then, some crashes / errors in the logging may occur

You mention "Your" front end. I generally utilize a separate development version of BOTH FE & BE When ?adequate? testing is done, I use a separate program to copy all changed objects in the development version to the production version. It is a simple matter to then change "my" password in the production version (or even delete my user from it). Another program checks the file date of the FE EACH time a user logs on to the app and automatically reloads the FE to the machine.

Perhaps a bit cumbersome but seemed to be effective for me.



MichaelRed


 
@MichaelRed,

A big cumbersome indeed! Some of it seems simple until you do the digging in. And same thing on the logging - it can get painful to make sure everything gets logged, for sure.


"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
On the other hand, it may not be that difficult.

Consider a table like this:

[pre]
MyUsersLog table
PK UserName Date_IN Date_OUT
1 BSMITH 12/12/2010 12:00:00 12/12/2010 12:30:00
2 SJONES 12/12/2010 15:00:00 12/12/2010 15:30:00
3 BBROWN 12/12/2010 12:00:00
[/pre]

UserName and Date_IN is not a problem, crashing and not updating Date_OUT is (a little). But let’s say you decide that crashing will show as 1/1/1900 as Date_OUT.

So when user logs in, you do something like:
(In case they crashed last time)[tt]

Update MyUsersLog
Set Date_OUT = #1/1/1900#
Where UserName = 'MyUserName'
And Date_OUT Is Null[/tt]

(and regular log in)[tt]
INSERT INTO MyUserLog (UserName, Date_IN)
VALUES('MyUserName', Now)[/tt]

And of course the ‘regular’ way out:[tt]
Update MyUsersLog
Set Date_OUT = Now
Where UserName = MyUserName[/tt]


Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
I know I'm coming in late on this. But if you need to know if a database is open, check FAQ Who has my database open? in the Access How To section of Other Topics
 
I use this function which I access via a button on my maintenance form

Code:
Function LDBViewer2010()
'Reference Microsoft ActiveX Data Objects for this code to work

Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
 Const conDatabase As String = "L:\HR Database\Employee Management Tool\Employee Management Tool.accde"

     ' Open connection to Access backend
    cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & conDatabase & ";Persist Security Info=False;"

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

     'Output the field list
    Debug.Print rs.Fields(0).Name, "|", rs.Fields(1).Name, "|", rs.Fields(2).Name, "|", rs.Fields(3).Name
Forms!names.Text0.Value = ""
allval = ""
     'Loop through users recordset of users in database.
    While Not rs.EOF
        allval = allval & vbCrLf & Trim(rs.Fields(0))
             
        rs.MoveNext
     Wend
         Forms!names.Text0.Value = allval
         DoEvents
     ' Close
    If rs.State <> adStateClosed Then rs.Close
     Set rs = Nothing
     Set cn = Nothing


End Function

Hope this is of use, Rob.[yoda]
 
robCarr,

I've been using that code for years. But I was always going after the workgroup file. Since 2007+ doesn't use workgroup files, I didn't think it would work. Didn't realize I could read the BE database. Which will work with most of my systems. But a few of my systems link the tables to a SQL server, so there is no BE db. But I do have an Access library db that I reference. I'll have to check to see if connecting to the library db will work.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top