Capture Users IP in Access

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When the frontend of my databse gets corrupted I need to log all the users
out, but some have left their desks etc so I don't know who's in the system
and who isn't.

Is there a way to capture users IPs in Access?
 
Thanks, I will try to implement this into my database, I seem to be missing the
Microsoft ActiveX Data Objects 2.1 Library
I have 2.0, 2.5,6,7,8 but not 2.1. Where do I get this from and will it need
to be installed on all my clients PCs for the Passive Shutdown to work?
 
"IPs"?

Do you mean IP addresses?

There is nothing built in to Access which would give you the IP
addresses of people connhecting to it via the internet. Is that what
you want?

TC
 
If you want the IP addresses, you can do a network
lookup from the name (a separate question), but I
think you will find the computer names more useful.

(david)
 
Yeh, that code will do the job, but I have no idea how to get it to output to
a text box

'Output the list of all users in the current database.

Debug.Print rs.Fields(0).Name, "", rs.Fields(1).Name, _
"", rs.Fields(2).Name, rs.Fields(3).Name

While Not rs.EOF
Debug.Print rs.Fields(0), rs.Fields(1), _
rs.Fields(2), rs.Fields(3)
rs.MoveNext
Wend

How can I make that print the output to a text box instead of the immediate
window?
 
In the Load event of the form, place code like this:

me.Text0 = rs.Fields(0).Name & "" & rs.Fields(1).Name _
""& rs.Fields(2).Name & rs.Fields(3).Name

While Not rs.EOF
me.Text0 = me.Text0 & vbCrLF _
& rs.Fields(0) & rs.Fields(1) _
& rs.Fields(2) & rs.Fields(3)
rs.MoveNext
Wend


Or, create a new blank report.

In the format event of the detail section, place this:

'Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
'Output the list of all users in the current database.
If FormatCount = 1 Then
me.Print rs.Fields(0).Name, "", rs.Fields(1).Name, _
"", rs.Fields(2).Name, rs.Fields(3).Name & vbcr

While Not rs.EOF
me.Print rs.Fields(0), rs.Fields(1), _
rs.Fields(2), rs.Fields(3) & vbcr
rs.MoveNext
Wend
'End Sub

(david)
 
Thanks for your help David, that half worked, the values from rs.Fields(0)
and (1) have some wierd chars after them which make them not display
following text properly in a text window so I had to do this:

txt0 = txt0 & vbCrLf & (Left(rs.Fields(0), (Len(RTrim(rs.Fields(0))) - 1)))
txt1 = txt1 & vbCrLf & (Left(rs.Fields(1), (Len(RTrim(rs.Fields(1))) - 1)))

Which deletes all the spaces and the bad char off the end of the string
I also split the results up into 4 text boxes so they'd all be lined up
properly (now that I understand the code this was quite easy) so my final
solution is this:

Private Sub cmdShowUser_Click()

Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim i, j As Long

Set cn = CurrentProject.Connection

' The user roster is exposed as a provider-specific schema rowset
' in the Jet 4.0 OLE DB provider. You have to use a GUID to
' reference the schema, as provider-specific schemas are not
' listed in ADO's type library for schema rowsets

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

'Output the list of all users in the current database.

txt0 = rs.Fields(0).Name
txt1 = rs.Fields(1).Name
txt2 = rs.Fields(2).Name
txt3 = rs.Fields(3).Name

While Not rs.EOF
txt0 = txt0 & vbCrLf & (Left(rs.Fields(0), (Len(RTrim(rs.Fields(0))) -
1)))
txt1 = txt1 & vbCrLf & (Left(rs.Fields(1), (Len(RTrim(rs.Fields(1))) -
1)))
txt2 = txt2 & vbCrLf & rs.Fields(2)
If rs.Fields(3) = 1 Then
txt3 = txt3 & vbCrLf & "1"
Else
txt3 = txt3 & vbCrLf & "Null"
End If
rs.MoveNext
Wend

End Sub


Quite a tasty piece of code, cheers David.
 
Back
Top