How can I update a table automatically with the network computer/user name

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pizzaface
    New Member
    • Apr 2010
    • 4

    How can I update a table automatically with the network computer/user name

    Hello: I'm wanting to update a Microsoft Access Table automatically with the network computer name and user name as soon as a user logs onto his/her computer. I would like this to happen with minimal disruption to the user. I have read about possibly using the Windows Scheduler or autoexec.bat to open an access database, run an autoexec macro, etc...I already know how to get the network computer name and user name. I'm looking for assistance with Windows scheduler, autoexec.bat or some other way of automatically updating the table. Thank you in advance for your assistance.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32656

    #2
    If it's when the user logs on then the scheduler would not be involved.

    What, precisely, are you hoping for here? Your question isn't very clear and has few details. Is the table just a single record that gets overwritten? Maybe it manages various PCs. Please give us all the details so that we can help.

    Comment

    • pizzaface
      New Member
      • Apr 2010
      • 4

      #3
      Reply to NeoPa

      I'm wanting to be able to keep track of an employee's location in our department. Sometimes employees move to different teams, sometimes they move because of a temporary assignment. I'm wanting to be able keep track of their location for emergencies, reports, etc...I have Microsoft tables set up (i.e. tblEmployees, tblEquipment) where I keep track of employees and equipment. The tblemployee table has two fields (i.e. txtEmployeeId, txtComputerName ) among others. txtComputerName is a primary key in the tblEquipment table and a foreign key in the tblEmployees table. When an employee logs on to a computer I would like retrieve the Computer Name and User Name from the network, run a query against the employee table looking for a match between the network User Name and the txtEmployeeID field. If a match is found then the txtComputerName field would be updated in the tblEmployees table with the network Computer Name of the computer they are currently logged onto. If they log on to a different computer then the program would update the txtComputerName field with the Computer Name of the new computer they logged on to. I know how to get the Computer Name and User Name from the network using VBA. However, I would like to be able to gather this information for each employee after they log onto their computer. I would the program designed so that the update process is invisible to the user or at least has minimal disruption to the employee. From reading postings on the internet, I believe I would have to add a line of code to the autoexec file in the startup folder that would open the Access database, run a macro to retrieve the network computer name and user id and update the tblEmployees table and then close the database. If you have any suggestions for using autoexec or any other method of updating the access table automatically upon logging into the network I would appreciate your assistance.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32656

        #4
        That's very much clearer and I think I can help with that.

        There are a number of issues here I suppose.
        1. Getting the User ID & PC Name.
        2. Open a database and automatically run VBA code (and probably close the database too) from the Command Line.
        3. How and when to invoke the process.

        1. These can quite reliably be retrieved from the Environment as UserDomain, UserName & ComputerName, yet there are other approaches that are even more reliable. I won't go into more detail here, but if you have VBA code to get this already then that's fine. The VBA function call to return a value from one of the Environment Variables is Environ().
          Code:
          Environ("UserName")
        2. You'll find full details of this in Invoking a Database From the Command Line.
        3. Autoexec.Bat is one approach (actually there are many). A possibly easier and more appropriate one might be to invoke it from within a Logon Script. The advantage here is that you only need set it up the once and you would have pretty full control over who gets to run it (even all, if that's your choice).

        Comment

        Working...