#1
  1. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jul 2012
    Posts
    18
    Rep Power
    0

    access welcome code


    well, not sure if the title is correct ._.

    here's my code, i use 2 forms Login and Menu
    Login Code:
    Code:
    Private Sub cmdLogin_Click()
        '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 to see if this
        'matches value chosen in combo box
    
        If Me.txtPassword.Value = DLookup("password", "tblUsers", _
                "[ID]=" & Me.cboUsername.Value) Then
    
            ID = Me.cboUsername.Value
    
            'Close logon form and open loginmenu form
    
         DoCmd.Close
         DoCmd.OpenForm "LoginMenu"
    
        Else
          MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
                "Invalid Entry!"
            Me.txtPassword.SetFocus
        End If
    what i want is after logging via the Login Form. in the Menu it should write "Welcome, "username"" but i don't know what to search in google. so i need your help

    There isn't any code in Menu just macros to link to other forms
    is there anyway to code it example:
    Username :staff (staff only have Read-Only permission)
    if i log in using "staff" from Login form, in Menu Form, after clicking on any of the forms "staff" won't be able to edit anything and it's only "staff" that is read-only when other username is logged in, they are able to edit it.
    Me.AllowEdits = false
    Me.allowaddition = false


    Thanks in advance
  2. #2
  3. Contributing User
    ASP Adventurer (500 - 999 posts)

    Join Date
    Jun 2011
    Location
    South Jersey
    Posts
    544
    Rep Power
    59
    You could use a global variable to store the username. Do a google search for global variables, there's plenty of documentation out there. Then just refer to your global variable anytime you need to identity the user.
  4. #3
  5. Moderator
    ASP Super Genius (4500 - 4999 posts)

    Join Date
    Apr 2009
    Location
    The Great Land
    Posts
    4,621
    Rep Power
    650
    Since you have process for user login, you have a table of user info - username, password, permission level?

    A global variable will work but can be an aggravation when debugging code because when code execution is terminated, often the global variable loses its value.

    I store user info on a form that always remains open, such as MainMenu, then it is always available for reference.
    I like to know if my suggestion helped you. One way to let me know is by clicking star at bottom left corner of post.
    Debug!Debug!Debug!http://www.cpearson.com/excel/debug.htm

Similar Threads

  1. Access form with VB code
    By mrsgwen in forum Microsoft Access Help
    Replies: 17
    Last Post: October 19th, 2007, 05:40 PM
  2. access code
    By asvathi in forum Code Bank
    Replies: 1
    Last Post: January 19th, 2005, 04:25 AM
  3. I Need Poll asp code for MS Access
    By KgbCia in forum ASP Free Lounge
    Replies: 0
    Last Post: September 8th, 2004, 10:55 PM
  4. Need ASP / MS ACCESS Password Code
    By sitebuilder69 in forum ASP Development
    Replies: 1
    Last Post: January 26th, 2004, 12:05 AM
  5. ASP code to access query in MS Access
    By kpsga in forum ASP Free Lounge
    Replies: 2
    Last Post: September 23rd, 2003, 11:23 AM

IMN logo majestic logo threadwatch logo seochat tools logo