Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Login in Access 2007

Posted on 2011-10-17
7
Medium Priority
?
228 Views
Last Modified: 2012-05-12
Hi Everyone,

I need some VBA coding to handle a two different kinds of users entering passwords in.  I have my code for an administration user when they enter password in, but I nned to have some coidng where when an ordinary user enterss their password a different menu form opens up.

My Coding:

Private Sub Form_Open(Cancel As Integer)
'On open set focus to combo box
Me.cboEmployee.SetFocus
End Sub

Private Sub cboEmployee_AfterUpdate()
'After selecting user name set focus to password field
Me.txtPassword.SetFocus
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("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 "Startup Screen"

        Else
        MsgBox "Password Invalid.  Please Try Again", vbOKOnly, "Invalid Entry!"
        Me.txtPassword.SetFocus
    End If
   
    End If

I have an Employee table that holds the User

with these fields:  lngEmpId, StrEmpName, StrEmpPassword, and StrAccess.


0
Comment
Question by:jjc9809
  • 3
  • 3
7 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 36980752
How do you identify whether the user is an Admin user and an ordinary user?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36980764
include the field "strAccess" in the rowsource of your combo box "cboEmployee", then in the afterupdate event, check the value of "strAccess" and proceed accordingly to open the "menu"


Private Sub cboEmployee_AfterUpdate()
'After selecting user name set focus to password field
'Me.txtPassword.SetFocus

select case me.cboEmployee.column(3)  'refers to the "strAccess" field
      case "admin"

       '  your codes here
 
     case "user"
         'your codes here

       
 

end select

End Sub



got the idea ?
0
 

Author Comment

by:jjc9809
ID: 36981419
Capricorn,

On the Row Source Select Statement, I put this:  SELECT [tblEmployees].[lngEmpID], [tblEmployees].[strEmpName].[strAccess] FROM tblEmployees;

I get error when it runs if you place the [strAccess] in there.

0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36981474


change this part

   select case me.cboEmployee.column(3)


with

    select case me.cboEmployee.column(2)


*note, set the column count property of the combo to  3

0
 

Author Comment

by:jjc9809
ID: 36981583
I get the attached error when I select the drop down for obo.employee:


ERROR--5-.pdf
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 36981664
change the ROwSource of your combo box to


 SELECT [tblEmployees].[lngEmpID], [tblEmployees].[strEmpName], [tblEmployees].[strAccess] FROM tblEmployees;
0
 

Author Comment

by:jjc9809
ID: 36982646
I finally got it to work.

Thanks
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question