Question : Need to convert a macro to VB code in Access and then insert additional code for Log In Screen

I have a log in screen which runs from the following Macro [Picture attached] and wish to convert to VB Code so I can add a password field and insert the following:

Need help to bring it all together

the TempVar![cboCurrentEmployee] part of the macro is important as this links to a field on mainform which shows [Employee Name] and a default value =[TempVars]!CurrentUserID]

I have also attached the code I will also be inserting to make all this work
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
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("strEmpPassword", "tblEmployees", _
            "[lngEmpID]=" & Me.cboEmployee.Value) Then
 
        lngMyEmpID = Me.cboEmployee.Value
 
        'Close logon form and open splash screen
 
        DoCmd.Close acForm, "frmLogon", acSaveNo
        DoCmd.OpenForm "frmSplash_Screen"
 
    Else
      MsgBox "Password Invalid. Please Try Again", 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 admin.", _
               vbCritical, "Restricted Access!"
        Application.Quit
    End If
 
End Sub

Answer : Need to convert a macro to VB code in Access and then insert additional code for Log In Screen

Here are screen shots of TestDatabaseMDB.mdb that I downloaded. cboCurrentEmployee has no macro specified in the after update event.  More important, the data base has no macros.

I see you are using Access 2007.  How did you convert the databases to mdb format?

I think you are asking that cboCurrentEmployee in form VO Database Control Menu be populated with the name selected in the form Login Dialog.  I did that in the attached DB.

 
cboCurrentEmployee
cboCurrentEmployee
 
 
 
 
 
Random Solutions  
 
programming4us programming4us