Consulting

Results 1 to 4 of 4

Thread: MULTIPLE USERS AND TIME STAMP

  1. #1
    VBAX Newbie
    Joined
    Aug 2023
    Posts
    1
    Location

    MULTIPLE USERS AND TIME STAMP

    Hello.

    Is there a way to have user and time stamp on a simple access file (*.accdb), that will be used by several users ( 5-6) that will just change and add thing in the file in different locations at the same time?

    And actually if it can work this way without loosing info while saving?

  2. #2
    VBAX Regular
    Joined
    Sep 2023
    Posts
    97
    Location
    It is a bit hard to understand what you're asking, so I'm going to make some generalized suggestions on using Access with multiple users.

    A good practice is to separate the "frontend" (the forms and reports) part from the "backend" (the data). This way the only file the users are running contains only the GUI.
    Split an Access database - Microsoft Support

    Consider the locking scheme to use, if multiple users attempt to edit the same record, then Access can stop all others until the first user is finished.
    Types of Locks (Access desktop database reference) | Microsoft Learn

  3. #3
    Quote Originally Posted by Xenia View Post
    Hello.

    Is there a way to have user and time stamp on a simple access file (*.accdb), that will be used by several users ( 5-6) that will just change and add thing in the file in different locations at the same time?
    And actually if it can work this way without loosing info while saving?
    Hello! Yes, you can add a user and time stamp to a simple Access file (*.accdb) that will be used by several users. However, you need to split the database into two parts: a front-end and a back-end. The front-end is the part of the database that contains the forms, reports, and queries that users interact with. The back-end is the part of the database that contains the tables and data.


    Once you have split the database, you can add a user and time stamp to each record in the table by using VBA code. You can use the Environ function to get the current user name and Now function to get the current date and time. Here’s an example of how you can add a user and time stamp to a table:


    Private Sub Form_BeforeUpdate(Cancel As Integer)
        Me![LastModifiedBy] = Environ("USERNAME")
        Me![LastModifiedDate] = Now()
    End Sub

    This code adds two fields to your table: LastModifiedBy and LastModifiedDate. When a user updates a record in the table, this code will automatically add their username and the current date and time to these fields.


    To ensure that multiple users can work on the database at the same time without losing data, you need to make sure that each user has their own copy of the front-end. You can store these copies on a shared network drive or SharePoint site so that all users can access them.
    Last edited by Aussiebear; 10-12-2023 at 05:31 AM. Reason: Added code tags to suppled code

  4. #4
    Banned VBAX Newbie
    Joined
    Nov 2023
    Posts
    1
    Location
    Quote Originally Posted by Xenia View Post
    Hello.

    Is there a way to have user and time stamp on a simple access file (*.accdb), that will be used by several users ( 5-6) that will just change and add thing in the file in different locations at the time?

    And actually if it can work this way without loosing info while saving?
    Yes, it is possible to have a user and timestamp on a simple Access file (*.accdb) that is used by multiple users simultaneously. Here's how you can achieve this:
    1. Create a table in your Access database to store the user and timestamp information. Include fields such as "Username," "Timestamp," and any other relevant information.
    2. Use VBA code to capture the current user and timestamp whenever a user makes changes to the database. You can use the "Environ" function to retrieve the username and the "Now" function to get the current timestamp. For example:

    ```vba

    Private Sub Form_BeforeUpdate(Cancel As Integer)
    Dim strSQL As String
    strSQL = "INSERT INTO TableName (Username, Timestamp) VALUES ('" & Environ("USERNAME") & "', _
    #" & Now & "#);"
    CurrentDb.Execute strSQL
    End Sub
    ```
    Replace "TableName" with the actual name of your table.
    Last edited by Aussiebear; 11-01-2023 at 08:53 PM. Reason: Added code tags to supplied code

Posting Permissions

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