ken <ge****@gmail.com> wrote:
ok what about...the posibility of one front end finding out who is
using the record that they are on...or maybe a way to identify in
front ends who is using the database?
This code builds a list of computer names that are currently connected
to the backend. Users of a system I use this in can still have the
program open at the first switchboard as there is no data access at that
time.
On Error GoTo GetCurrentUsers_err
Dim cn As New ADODB.Connection
Dim cn2 As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim i, j As Long, ds As String
Dim ComputerName As Variant, UserName As Variant
DoCmd.SetWarnings False
DoCmd.RunSQL "DELETE * FROM appCurrentUsers;"
DoCmd.SetWarnings True
ds = GetDataLocation() ' a function a returns the path to the backend
database
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.Open "Data Source=" & ds
'cn2.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & ds
Set rs = cn.OpenSchema(adSchemaProviderSpecific, _
, "{947bb102-5d43-11d1-bdbf-00c04fb92675}")
Dim rsOut As DAO.Recordset
Set rsOut = CurrentDb.OpenRecordset("appCurrentUsers",
DB_OPEN_DYNASET)
With rsOut
While Not rs.EOF
UserName = Trim(rs.Fields(1))
UserName = Left(UserName, Len(UserName) - 1)
ComputerName = Trim(rs.Fields(0))
ComputerName = Left(ComputerName, Len(ComputerName) - 1)
.AddNew
If UserName = "Admin" Then
![UserName] = CurrentUser
![Computer] = ComputerName & " (local)"
Else
![UserName] = UserName
![Computer] = ComputerName
End If
![Connected] = rs.Fields(2)
![SuspectState] = rs.Fields(3)
.Update
rs.MoveNext
Wend
End With
--
regards,
Bradley
A Christian Response
http://www.pastornet.net.au/response