Results 1 to 3 of 3
  1. #1
    joym is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2017
    Posts
    57

    Exclamation Passing text in same form and other forms

    i created a login page with 2 fields txtLoginID and txtpassword



    When i press ok if the user name and password is correct i open the form [TT form] i push the username for that particular ID to the field me.txtusername on form [TT Form]

    Code:
    Private Sub btn_Ok_Click()
    
    Dim ID As Integer
    
    ID = DLookup("LoginID2", "Login", "Username = '" & Me.txtLoginID.Value & "'")
    
    DoCmd.OpenForm "TT Form", , , , acFormAdd
    Forms![TT Form]![txtUser] = Name
    
    End Sub
    This works fine intially however the form [TT Form] is used to create new records and has a save button which saves the record if all fields have been filled.

    Since it is used to add records after executing the save command. it clears all fields including the me.txtusername.

    I want the username of the person logged in to still be displayed until the user logs out.

    Also there is a 2nd form [Edit] where you can update the existing TT that have been created. You i have a button to take you back to TT form to create a new record

    I want the name of the person who is logged in to be displayed on the TT form in
    me.txtusername every time after a ticket is lodged or the TT form page is opened.

    So basically i want to
    1. save the value of me.txtusername and display the same value in the same text field in the new record.
    2. if i go to update field i would want to save the value of me.txtusername and when i open TTform from the update form to again display the value
    Last edited by joym; 05-25-2017 at 09:07 PM.

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Keep the login page open and always refer back to it - Forms!LoginPage!txtLoginID - this can be used everywhere without you having to pass it along.

    The login can be taken from Environ("username") and does not need to be entered by the user. Then they won't need a password, the table where the users are kept can determine if it is a valid user or not. Passwords get forgotten and should be avoided whenever possible.

  3. #3
    joym is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2017
    Posts
    57
    Umm the login page is only to use to enter username and password and once that is accomplished i donot see why that page should be kept open. and also even if i did leave the login in age open from my understanding it would not work, as my initial code uses the user name to identify the user name and when you click ok to login login is only successful if username and password for that user is correct only then does it send the users name to the textbox me.txtusername.

    So even if i did leave the login page open unless the userID is still in the userID text field i do not think it can be used to push user name to the required text field

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

Similar Threads

  1. Replies: 2
    Last Post: 07-01-2015, 11:39 AM
  2. Passing parameter between forms
    By jamedadi in forum Forms
    Replies: 5
    Last Post: 11-11-2013, 02:53 PM
  3. Replies: 3
    Last Post: 07-20-2012, 11:55 PM
  4. Replies: 2
    Last Post: 03-01-2012, 12:21 PM
  5. Replies: 3
    Last Post: 06-02-2009, 09:51 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