Hello,
I am trying to make a login screen for my database, but I need to track down the user that is enetering the information.
Therefore I created a form named frmLogin this is the code for that form
**************
Private Sub User_AfterUpdate()
Me![Password].SetFocus
End Sub
Private Sub cmdLogIN_Click()
On Error GoTo Err_cmdLogIN_Click
If Me![Password] = Me![User] Then
DoCmd.OpenForm "Ecran_PCP_form"
DoCmd.Close acForm, "frmLogin"
Else
MsgBox ("Mots de passe invalide")
Me![Password] = ""
Me![User].SetFocus
Me![Password].SetFocus
DoCmd.CancelEvent
End If
Exit_cmdLogIN_Click:
Exit Sub
Err_cmdLogIN_Click:
MsgBox Err.description
Resume Exit_cmdLogIN_Click
End Sub
Private Sub cmdLogOUT_Click()
Audit (2)
DoCmd.Close
End Sub
****************
I also have the following in my module
*********
Public Function Audit(intTrackingNumber As Integer) As Boolean
Dim db As Database ' define database
Dim rs As Recordset ' define recordset
Set db = CurrentDb ' Set database variable
Set rs = db.OpenRecordset("tblAudit", dbOpenDynaset) ' Set recordset
With rs
.AddNew
.Fields("AuditNumber") = intTrackingNumber
.Fields("User") = Forms![Ecran_PCP_form]![userId]
.Update
End With
End Function
*************
In my Main form named "Ecran_PCP_form"
I have the following
*********
Private Sub Form_Open(Cancel As Integer)
'Open form fullscreen when it has focus
DoCmd.Maximize
Me![userId].Value = Forms![frmLogin]![User].Column(0)
DoCmd.Close acForm, "frmLogin"
Audit (1)
End Sub
Private Sub Btn_Log_Click()
DoCmd.OpenForm "frmLogin"
End Sub
*************
The on all the other form where the user enters a call I have the following..
**********
I have a UserID text box
that username appears into and everything saves...
I also have a tbl name tblAudit and tblAuditDescription
therefore
1= LogIn
2= Log out
Evrythign works fien but the problem is that I want the user to be able to changer user just by clicking on the change user button on the main form without having to quit the whole program ..
I am trying to make a login screen for my database, but I need to track down the user that is enetering the information.
Therefore I created a form named frmLogin this is the code for that form
**************
Private Sub User_AfterUpdate()
Me![Password].SetFocus
End Sub
Private Sub cmdLogIN_Click()
On Error GoTo Err_cmdLogIN_Click
If Me![Password] = Me![User] Then
DoCmd.OpenForm "Ecran_PCP_form"
DoCmd.Close acForm, "frmLogin"
Else
MsgBox ("Mots de passe invalide")
Me![Password] = ""
Me![User].SetFocus
Me![Password].SetFocus
DoCmd.CancelEvent
End If
Exit_cmdLogIN_Click:
Exit Sub
Err_cmdLogIN_Click:
MsgBox Err.description
Resume Exit_cmdLogIN_Click
End Sub
Private Sub cmdLogOUT_Click()
Audit (2)
DoCmd.Close
End Sub
****************
I also have the following in my module
*********
Public Function Audit(intTrackingNumber As Integer) As Boolean
Dim db As Database ' define database
Dim rs As Recordset ' define recordset
Set db = CurrentDb ' Set database variable
Set rs = db.OpenRecordset("tblAudit", dbOpenDynaset) ' Set recordset
With rs
.AddNew
.Fields("AuditNumber") = intTrackingNumber
.Fields("User") = Forms![Ecran_PCP_form]![userId]
.Update
End With
End Function
*************
In my Main form named "Ecran_PCP_form"
I have the following
*********
Private Sub Form_Open(Cancel As Integer)
'Open form fullscreen when it has focus
DoCmd.Maximize
Me![userId].Value = Forms![frmLogin]![User].Column(0)
DoCmd.Close acForm, "frmLogin"
Audit (1)
End Sub
Private Sub Btn_Log_Click()
DoCmd.OpenForm "frmLogin"
End Sub
*************
The on all the other form where the user enters a call I have the following..
**********
I have a UserID text box
that username appears into and everything saves...
I also have a tbl name tblAudit and tblAuditDescription
therefore
1= LogIn
2= Log out
Evrythign works fien but the problem is that I want the user to be able to changer user just by clicking on the change user button on the main form without having to quit the whole program ..