Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2012
    Posts
    5

    Unanswered: Need Assistance With Basic VB Module / Return String

    Hello,

    I am a bit new to VB & Access. I Had wrote a simple program designed for my company to input / request & send new quotes. I do feel thatsome of it was done incorrectly but it works.. I am now creating a much larger program & data base to replace one that coded years ago by prior owner. Unfortunately he wrote the software to work with specific programs that are now no longer supported. I ordered a few books off the internet but after goggling found i will find much more success and help from working with other user's like yourself.

    The new software i am writing is for international shipping company. I understand that ACCESS can use its own CurrentUser() feature for security however i needed to create my own login prompt. I have a table Named "Users" which contains an autonumber Id / UserName & password. I created a form (AECLmainlogin) which has a combo box (AECLusername) where user is selected from the table column 1. I then have a textbox named (AECLpassword) where the user entered their numeric / alpha password & a command button (AECLmainloginCmd) which sets the code in action.

    Upon Clicking the command it calls "CheckLogin ()" which is a module i created. It verifies the username & password are correct in the table, if not clear password & msgbox " enter password ". This part works 100%.

    Once this happens what i need to have happen is to open a new form (AECLmainmenu). On that mainmenu & through the rest of the forms i create (based on different tables for the auctual shipping information) I have created a menu bar at the top. On that menu bar i need it to show the current user which was logged in. I have tried many different things.. some with partial success.. I had written a module which was called GetUserName() I then set the control of the New Textbox on the menu bar to GetUserName() Sometimes it writes ?NAME & Othertimes it will show the user but overwrites the information on line 1 table "USERS". Here is what i have.. im very confused and appreciate any help or guidance on how i can accomplish this with or without the code i wrote. The attached is just test db i have been using to figure this out. Username/ pw are in there.
    __________________________________________________ __________________________________________________ ______________________________
    This is my login form i created Form_AECLmainlogin

    Option Compare Database

    Public Sub AECLmainloginCmd_Click()
    Call CheckLogIn
    End Sub

    __________________________________________________ __________________________________________________ _______________________________
    This is my module - CheckMainLogin

    Option Compare Database

    Public Function CheckLogIn()
    ''Check that User is selected

    If IsNull(Form_AECLmainlogin.AECLUserName.Column(0)) Then
    MsgBox "You need to select a user!", vbCritical
    Form_AECLmainlogin.AECLUserName.SetFocus

    Else

    'Check for correct password to be correct. if yes it opens mainpage if not go back to login
    If Form_AECLmainlogin.AECLpassword = Form_AECLmainlogin.AECLUserName.Column(1) Then
    Call GetCurrentUserLoggedIn
    DoCmd.OpenForm ("CurrentUserName")

    Else

    MsgBox "Password does not match, please re-enter!", vbOKOnly, "Password Incorrect"
    Form_AECLmainlogin.AECLpassword = Null
    Form_AECLmainlogin.AECLpassword.SetFocus
    End If
    End If
    End Function

    __________________________________________________ __________________________________________________ ______________________________
    This is my module - GetUserLogin

    Option Compare Database
    Dim UserName As String

    Public Function GetCurrentUserLoggedIn()

    UserName = Form_AECLmainlogin.AECLUserName
    GetCurrentUserLoggedIn = UserName

    End Function
    Attached Files Attached Files

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    why create your own login form, why re invent the wheel
    for me the network logon is good enough. rely on the network logon, let that manage passwords. all I do do is assign the network logon user id to user groups as normal then query the security object to find is a user has adequate clearance.
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Mar 2012
    Posts
    5
    Thank you for the reply. I then can access that username at any time correct? I had intended to be able to give different users different levels of clearance. That way i could switch users without switching Net Logins. I certainly know that you guys are very experienced with this.. so i will take your advise. Im not sure how to code using the wheel thats already invented?! If that makes sense.

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
  •