Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2013
    Posts
    3

    Question Unanswered: Help: Login to specific record on form

    UNSOLVED MYSTERY
    I have been trying for weeks to get my login form to open up to a specific record on the mainform. I have built a form out of my Employee tbl (mainform). The table stores (ID,Name, password, EmpNumber ect.) I built a subform in that allows the user to type in the number of overtime worked on a paticular day. I have disabled the navigation on the main form so users can't advance to the next user but have enable the natigation on the subform so a particular user can advance to the next week of available overtime to input data.

    I am attaching the file. The goal is to get user login form to display a particular record on the main form and open a different form in the user is a supervisor.
    Option Compare Database
    Private intLogonAttempts As Integer
    Private Sub cmdExit_Click()
    DoCmd.Quit
    End Sub
    Private Sub cmdLogin_Click()
    'Check to see if data is entered into the UserName combo box
    If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
    MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
    Me.cboEmployee.SetFocus
    Exit Sub
    End If
    'Check to see if data is entered into the password box
    If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
    MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
    Me.txtPassword.SetFocus
    Exit Sub
    End If
    'Check value of password in tblEmployees to see if this matches value chosen in combo box
    If Me.txtPassword.Value = DLookup("EmpPassword", "tblEmployeesLog", "[EmpID]=" & Me.cboEmployee.Value) Then
    MyEmpID = Me.cboEmployee.Value
    'Close logon form and open splash screen

    DoCmd.Close acForm, "frmLogin", acSaveNo
    DoCmd.OpenForm "frmEmpOt"
    Else
    MsgBox "Password Invalid. Please Try Again", vbCritical + vbOKOnly, "Invalid Entry!"
    Me.txtPassword.SetFocus
    End If

    'If User Enters incorrect password 3 times database will shutdown

    intLogonAttempts = intLogonAttempts + 1
    If intLogonAttempts > 3 Then
    MsgBox "You do not have access to this database. Please contact your system administrator.", vbCritical, "Restricted Access!"
    Application.Quit
    End If

    End Sub
    Attached Files Attached Files

  2. #2
    Join Date
    Nov 2011
    Posts
    413
    You did not say what record you wanted it to open to? Record Number or criteria?

    With Me.Recordset
    .FindFirst "YourID = " & SomeID
    If .NoMatch Then MsgBox SomeID & " was not found"
    End With
    Last edited by Burrina; 08-21-13 at 12:14. Reason: Example

  3. #3
    Join Date
    Aug 2013
    Posts
    3
    Thank you for replying. The form I would like to open in called frmEmpOt. I would like that form to open to the record of the person who logged in.

  4. #4
    Join Date
    Nov 2011
    Posts
    413
    Then use the above code and enter the employees ID.

  5. #5
    Join Date
    Aug 2013
    Posts
    3
    DoCmd.OpenForm "frmEmpOt",,,"[EmpID]=" & MyEmpID

    was the answer which is somewhat you said thanks alot tho I'm sure I'll have more answer

  6. #6
    Join Date
    Nov 2011
    Posts
    413
    Glad you got it working. Good Luck with your project!

  7. #7
    Join Date
    Oct 2013
    Posts
    1
    Hello plditch,

    I'm having the same problem you had. I want to make a login form that will open a form with a specific record. Can you post the sample of your login form so that I can check on how you made it work? Thanks so much.

Tags for this Thread

Posting Permissions

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