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

    Join Date
    Jul 2012
    Rep Power

    access welcome code

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

    here's my code, i use 2 forms Login and Menu
    Login 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"
            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.OpenForm "LoginMenu"
          MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
                "Invalid Entry!"
        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
    South Jersey
    Rep Power
    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
    The Great Land
    Rep Power
    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.

Similar Threads

  1. Access form with VB code
    By mrsgwen in forum Microsoft Access Help
    Replies: 17
    Last Post: October 19th, 2007, 06:40 PM
  2. access code
    By asvathi in forum Code Bank
    Replies: 1
    Last Post: January 19th, 2005, 05: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, 11:55 PM
  4. Need ASP / MS ACCESS Password Code
    By sitebuilder69 in forum ASP Development
    Replies: 1
    Last Post: January 26th, 2004, 01: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, 12:23 PM

IMN logo majestic logo threadwatch logo seochat tools logo