Results 1 to 14 of 14
  1. #1
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727

    After Password Login Form


    How do I link the text field of the username on the login screen to auto fill that username in another text field in another form so I know who is logged in and who will be adding this new record? I'm also thinking of making this text field locked so the user will not be able to change the username once its auto filled into the second form from the login form.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    What is the other form - an unbound 'menu'? If it is just a 'menu' form, can bind it to the Users table and open it filtered to the username.

    If it's an otherwise bound form, several ways to pass the value.

    1. Open the other form and code references the login textbox and sets value of textbox on other form
    then close the login form
    DoCmd.OpenForm "formname"
    Forms!formname.tbxUser = Me.Username
    DoCmd.Close

    2. pass the username with OpenArgs argument,
    DoCmd.OpenForm "formname", , , , , Me.Username
    textbox expression on other form references the OpenArgs property
    =[OpenArgs]
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727
    Hey June7,

    thank you for the reply. The log in form I am using has VBA code for all the usernames and passwords. I found this to be the better solution for now because I can lock the VBA Editor from view. This way the user will not have access to the usernames and passwords.

    As for the process of how the forms flow....the first form that pops up is a splash screen form which its only purpose is basically for pseudo load screen. After that comes the login screen. The user will then enter the username and password. After this is another splash screen then the main menu. From there the user will decide on 2 forms to create records. Which ever form the user chooses, is the form I need one of the fields to show who is logged in. The user may also go back and forth between these forms if that matters. The field in question that will have this auto fill feature to show who is logged in, I will lock it so the user cannot edit this field and it will also show the user who is logged in, in case they want to log out and log back in to use their account.

    Names of the text fields and forms:
    Username field = txtusername
    Password field = txtpassword
    Field to auto fill the user name = Clerk Initial (this field is on the form called DL Clearance)
    Other Field to auto fill the user name = Clerk Initial (this field is on the form called MV Registration Clearance)

    Order of the flow of forms:
    1. Splash Screen
    2. Login
    3. Splash Screen 2
    4. Main Menu
    5. Either DL Clearance or MV Registration Clearance

    Let me know if you need any other info. Thanks again.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Well, what do you think of the options already described?

    There is also global variable. However, they can be aggravating during development because if code execution is interrupted, the variables lose value.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727
    Ok. If I understand correctly, the second option you listed above sounds like it would work better since the first option may get interrupted with the splash screen 2 and main menu forms opening before the form that I want the auto fill to work on. Does this sound right to you? Since the code you provided does close the login form at the end it will lose reference if the user changes between forms as they navigate through the flow of all the forms.

    Also will this be a problem if the user changes back and forth between these 2 forms which I want the auto fill to work on? DL Clearance and MV Registration Clearance?

    Unless, getting back to the first option, I could keep the login screen open but make it invisible after the user logs in. This way the forms that open afterwards can always reference the username from the invisible but open login form. I'm just not sure its possible to make an entire form invisible. What do you think about this method?

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Close the login form at whatever point in the process you want - or hide it. Not visible forms can still be referenced.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727
    Is the first option going to pull the username from the actual text field in the login in form? Or do I have to create a table for the login form and then the code will pull the username from that table into the other form (DL Clearance or MV) that has the field I want to auto fill?

    Also how will this all work if I have multi users using this database simultaneously? This is a front end/back end database.

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Each user should have their own copy of the front end.

    The code in either option passes the value of the login form textbox, regardless of how the textbox is populated.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727
    Hey June7,

    I was just about to try out the code you provided above but I don't see how this is going to work since my flow of forms is not in the order that your code is asking for. In your code that you provide isn't it saying that right after the user logs in from the log in form that it will auto fill the field in the next form that opens then right after that it will close the log in form? If you look at the order of how the forms are presented to the user, it won't be the next form from the log in form. After the log in form will be a splash screen form then a main menu form then the user will have a choice between 2 forms. On those 2 forms which ever the user chooses, I would like for the username to be auto filled in one of the fields. So how to you code for this scenario? I'm thinking I will have to keep that log in form open till the user gets to the right form to auto fill?

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Adapt. Structure the code to suit your setup. There are many ways to accomplish. Leave the login form open till the 'right' form is opened and then have that form close the Login. Or code behind the Login can set to not visible and leave it open but hidden. Or pass the value to each subsequent form. Or use a global variable.

    I don't use 'splash' screens. What purpose do they serve in your db?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727
    I tried sticking this in the On Open event for the DL Clearance form that I want to auto fill for a field called Clerk Initial:

    Forms!Login.txtUsername = Me.[Clerk Initial]

    That did not work. It was done even while the login form was still open but hidden.

    Now I am trying to use the OpenArgs way but have no idea how this works. Do I just put the =[OpenArgs] expression right into the text field on the DL Clearance form? I also put in the DoCmd command on the button on the main menu that will open the DL Clearance form but that Me.Username is not working.

    2. pass the username with OpenArgs argument,
    DoCmd.OpenForm "formname", , , , , Me.Username
    textbox expression on other form references the OpenArgs property
    =[OpenArgs]

  12. #12
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Aren't you trying to pull value from Login form? Try reversing the expression:

    Me.[Clerk Initial] = Forms!Login.txtUsername


    Expression in textbox will not save value to table. That requires code - VBA or macro.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #13
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727
    Thanks June7. Now it works. I'm just having trouble figuring out why its saving 2 records when I hit the save/print button. I'll ponder on it a bit and see if I can resolve it. I'll be back to post the end results to close this God forsaken thread.

    Thanks again for helping me out.

  14. #14
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727
    Well after much testing and testing this is the code I had to use:

    Private Sub cmdSavePrint_Click()

    If Not IsNull(Me.Serial_DL) Then
    DoCmd.GoToRecord , , acNewRec
    MsgBox "Record has been saved. To delete record, report to a Supervisor."
    DoCmd.PrintOut
    Else
    DoCmd.CancelEvent
    Beep
    MsgBox "No changes were made.", vbInformation, "Required Data"
    DoCmd.GoToControl "[Division]"
    End If

    End Sub

    Then I had to get rid of your code because the docmd.printout was causing some crazy problems. Records getting saved twice, one record is filled out and the other was blank. Then I tried swapping the print and acnewrec code around but then it would error out saying that the acnewrec was not available right now. So I actually got it to work with a super long code but what I didn't like is that it was wasting primary keys. So what I realized that was causing all the problems was the fact that the code you gave was like a data entry to the form. So I deleted Me.[Clerk Initial] = Forms!Login.txtUsername and switched the default value property instead to the Clerk Initial field. Then everything worked perfectly because it won't use a primary key until the other fields are filled out. I also locked the clerk initial field so the user can't touch it.

    Anyway, thanks for always helping me out and sorry if my questions are stupid. The next thing I'm going to tackle is locking down the database. So get ready for more stupid questions. lol

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Password Login Forms
    By data808 in forum Access
    Replies: 1
    Last Post: 02-20-2014, 11:41 AM
  2. Login Form with Password
    By data808 in forum Programming
    Replies: 1
    Last Post: 02-12-2014, 01:06 PM
  3. Password ### login
    By buckwheat in forum Access
    Replies: 5
    Last Post: 09-10-2013, 11:54 AM
  4. Replies: 3
    Last Post: 06-22-2012, 04:19 PM
  5. Problem with User Login and Password
    By sk88 in forum Access
    Replies: 3
    Last Post: 12-16-2011, 08:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums