Results 1 to 5 of 5
  1. #1
    dylgue is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Feb 2018
    Posts
    2

    Question Problem with Dlookup on my project

    Hello,

    I try to resolve the problem myself, but I don't.

    I found a code on the web to know which person use an access application, and I try to modify a part for my utilisation.


    Code:
    ' Nouvel utilisateur
            Set loUser = New clLDBUser
            loUser.ComputerName = TrimNull(StrConv(lBuffer1, vbUnicode))
                ' Test l'utilisateur en fonction du ComputerName
            loUser.UserName = DLookup("[Utilisateur]", "Users", "[Poste]=" & loUser.ComputerName)
            loUser.NumConnection = lNbUser
    When I run the application, the field "UserName" is complete by "Admin" for every users but I want to know the name of the person who use the PC.

    So I make a table "Users" with 2 row : '[Poste]' and '[Utilisateur]'. With this table, I can found who match with the good Computer.

    But I don't understand how I can use the variable loUser.ComputerName on my Dlookup function.



    When I try to compare '[Poste]=' with a String, I found the name, but with the variable it's notificate me "error '91' " or " The value xxx create an error" where xxx = the loUser.ComputerName


    If someone could help me ?

    Thank you by advance.

  2. #2
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    Use these: Environ("UserName") and Environ("ComputerName")

    You can store both items in a table when users start your application .... together with login date/time if you want
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    or on a form. Then i use the form values for queries.

  4. #4
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    The reason I mentioned a table is so you can have a user login history.
    If you don't need that just use a form as ranman suggested.
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  5. #5
    dylgue is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Feb 2018
    Posts
    2
    Thank you all ! It works

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 12-14-2014, 05:06 AM
  2. DLookUP problem
    By Symlink in forum Access
    Replies: 7
    Last Post: 03-28-2013, 11:03 AM
  3. Problem with DLookup
    By MichealShinn in forum Programming
    Replies: 5
    Last Post: 01-25-2012, 09:08 AM
  4. Autonumber Problem in adp project
    By dneruck in forum Access
    Replies: 8
    Last Post: 04-22-2010, 09:43 AM
  5. Dlookup problem
    By CalifDan in forum Reports
    Replies: 4
    Last Post: 12-09-2009, 06:09 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums