Results 1 to 9 of 9
  1. #1
    Join Date
    Mar 2004
    Posts
    5

    Unanswered: Workgroup User Level Security

    I'm using a Workgroup User Level security setup on a database - is it possible to get the username of the person who's logged in to appear on a form within the Db?

  2. #2
    Join Date
    Nov 2003
    Location
    Europe
    Posts
    369

    User Roster (Access 2000+)

    "The user roster allows you to programatically determine who is logged on to a database. The OpenSchema method of the Connection object provides this information"

    (ref. Allister Balter's Mastering Access 2002, excellent book/lookup - highly recommended :-) )

    Code sample:

    Sub UserRoster()
    Dim cnn As ADODB.Connection
    Dim rst As ADODB.Recordset

    Set cnn = New ADODB.Connection
    cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\My Documents\Test.mdb"
    cnn.Open

    Set rst = cnn.OpenSchema(adSchemaProviderSpecific, _
    , JET_SCHEMA_USERROSTER)
    Debug.Print rst.GetString
    End Sub

    Daniel.

  3. #3
    Join Date
    Nov 2003
    Location
    Europe
    Posts
    369

    Re: User Roster (Access 2000+)

    Originally posted by kedaniel
    (ref. Allister Balter's Mastering Access 2002, excellent book/lookup - highly recommended :-) )
    ooops, its the other book in that 2-book "series":
    Alison (not Allister...) Balter's Mastering Access 2002 Enterprise Development...

    D.

  4. #4
    Join Date
    Mar 2004
    Posts
    5

    Re: User Roster (Access 2000+)

    Realise this shows my stupidity but can i be a real pain and ask for some specifics of how to put this into practice - i can twig that the
    Source=C:\My Documents\Test.mdb" just needs to link to my DB instead - but where in the source of the form should i add this to avoid damage, and what would the control source of a field to reference this be?

    Appreciate the help so far - this place is tops :-)

    Steve

    Originally posted by kedaniel
    "The user roster allows you to programatically determine who is logged on to a database. The OpenSchema method of the Connection object provides this information"

    (ref. Allister Balter's Mastering Access 2002, excellent book/lookup - highly recommended :-) )

    Code sample:

    Sub UserRoster()
    Dim cnn As ADODB.Connection
    Dim rst As ADODB.Recordset

    Set cnn = New ADODB.Connection
    cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\My Documents\Test.mdb"
    cnn.Open

    Set rst = cnn.OpenSchema(adSchemaProviderSpecific, _
    , JET_SCHEMA_USERROSTER)
    Debug.Print rst.GetString
    End Sub

    Daniel.

  5. #5
    Join Date
    Mar 2004
    Posts
    29
    Assuming that the database is password protected what would your code look like?

  6. #6
    Join Date
    Nov 2003
    Location
    Europe
    Posts
    369

    Re: User Roster (Access 2000+)

    Originally posted by stek2003
    where in the source of the form should i add this to avoid damage, and what would the control source of a field to reference this be?
    Appreciate the help so far - this place is tops :-)
    Steve
    Try creating a standard command button, and put the code behind its OnClick event. I really havent tried this function myself, but that is the first that comes to mind.

    Daniel

  7. #7
    Join Date
    Mar 2004
    Posts
    5

    Re: User Roster (Access 2000+)

    Just did that - didn't really seem to do anything but didn't generate any errors...?

    Originally posted by kedaniel
    Try creating a standard command button, and put the code behind its OnClick event. I really havent tried this function myself, but that is the first that comes to mind.

    Daniel

  8. #8
    Join Date
    Mar 2004
    Posts
    33

    Re: Workgroup User Level Security

    Originally posted by stek2003
    I'm using a Workgroup User Level security setup on a database - is it possible to get the username of the person who's logged in to appear on a form within the Db?

    In the forms' Open Event Procedure, use the following:

    txt_CurrentUser = CurrentUser() ' txt_CurrentUser is an unbound text box on your form. You can then use the value of the text box for later manipulation.

  9. #9
    Join Date
    Nov 2003
    Location
    Europe
    Posts
    369

    Re: Workgroup User Level Security

    Originally posted by toliver
    In the forms' Open Event Procedure, use the following:

    txt_CurrentUser = CurrentUser() ' txt_CurrentUser is an unbound text box on your form. You can then use the value of the text box for later manipulation.
    that will get the name of YOUR user, not the name of another user that is currently logged in, and will not provide a list if there is more users logged in simultaneously.

    Daniel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •