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!