Results 1 to 4 of 4
  1. #1
    ratercero is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2017
    Posts
    16

    logged register user who made change


    Hello, I have a login form that displays different menus depending on the user. I’m saving as a variable the user name and intend to use it on all the forms to register the user that changed fields.

    it does not seem to work on the other forms, here is the code on the login:

    Code:
    Private Sub BTINGRESAR_Click()
    
    
    'select the navigation pange
    Call DoCmd.NavigateTo("acNavigationCategoryObjectType")
    'hide the selected object
    Call DoCmd.RunCommand(acCmdWindowHide)
    
    
    
    
    If IsNull(Me.TXTUSUARIO) Then
    MsgBox "Ingrese Nombre de Usuario", vbInformation, "Usuario requerido"
    Me.TXTUSUARIO.SetFocus
    
    
    ElseIf IsNull(Me.TXTCONTRASENA) Then
    MsgBox "Ingrese Contraseña", vbInformation, "Contraseña requerida"
    Me.TXTCONTRASENA.SetFocus
    Else
    
    
    
    
    Dim CURRENTUSER As String
    
    
    CURRENTUSER = TXTUSUARIO.Value
    
    
    
    
    Dim rs As Recordset
    
    
    Set rs = CurrentDb.OpenRecordset("Accesos", dbOpenSnapshot, dbReadOnly)
    
    
    rs.FindFirst "Usuario='" & Me.TXTUSUARIO & "'"
    
    
    If rs.NoMatch = True Then
    Me.LBL_INCORRECTO.Visible = True
    Me.TXTUSUARIO.SetFocus
    
    
    
    
    
    
    Exit Sub
     
     End If
     
    If rs!Contrasena <> Me.TXTCONTRASENA Then
    Me.LBL_INCORRECTO.Visible = True
    Me.TXTCONTRASENA.SetFocus
    
    
    
    
    Exit Sub
     
     End If
     
     If rs!Nivel = "Total" Then
      
    DoCmd.OpenForm "MENU"
    DoCmd.Close acForm, Me.Name
     Else
    DoCmd.OpenForm "MENU_2"
    DoCmd.Close acForm, Me.Name
     
    
    
    End If
    End If
    
    
    
    
    End Sub
    and this is the code to call the CURRENTUSER variable on the other forms:

    Code:
    Private Sub CMB_CLIENTE_AfterUpdate()
    
    Fecha_de_Modificacion = Now
    
    
    Actualizado_por = CURRENTUSER
    
    
    End Sub
    I apreciate any advice.

    thanks!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The variable is declared within a sub, thus only available within that sub. Declare it as public in a standard module, or use a TempVar, or put it in a hidden form control on a form that stays open.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ratercero is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2017
    Posts
    16
    Thank you pbaldy,

    Considering this is a front end wich one is better for me? if 3 users are logged in it should record the name of each on the changes they make.

    I your can provide the know how it would be great.

    RT

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    All should work, so whichever you're most comfortable with.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 4
    Last Post: 10-29-2016, 12:20 AM
  2. Logged In user Names
    By Parminder in forum Access
    Replies: 5
    Last Post: 07-23-2015, 02:17 PM
  3. logged user name on main form
    By foxtet in forum Forms
    Replies: 1
    Last Post: 07-30-2011, 03:00 PM
  4. Getusername of currently logged in user
    By nkuebelbeck in forum Access
    Replies: 8
    Last Post: 06-29-2011, 04:06 PM
  5. Currently logged in user into text box
    By ne16428 in forum Security
    Replies: 5
    Last Post: 06-10-2009, 11:46 AM

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