Results 1 to 7 of 7
  1. #1
    veejay is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Nov 2018
    Location
    Montreal, Canada
    Posts
    46

    fOSUserName as default and matching full name

    I'm using a module that allows me to use the fOSUserName to grab the user computer login.

    I have create a table for my reviewers called Reviewer_Table where I added all the computer login in a column and a second column for their full name.

    In my main form I have a combo box to select a reviewer (by full name) from that Reviewer_Table. In the same combo box I set the default option to =fOSUserName() so when my reviewer log in they already have their information there. This value is recorded in a Quality_Table Under "Reviewer".

    What I want to achieve:

    1- Transform the login to their full name in the output table (and the form if possible) rather than their computer ID


    2- Keep the ability to manualy change the reviewer name via the combo box

    I did read something about dlookup or something but keep in mind that I started using Access back in December and I am not trained as a tech person

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    in a form, when the form loads, fill in a text box with UserID (locked textbox)
    grab the Name from the table:

    txtUserName = Dlookup("[UserName]","Reviewer_Table ","[userID]='" & me.txtUserID & "'")

    then run any query using the objects on the form.

  3. #3
    veejay is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Nov 2018
    Location
    Montreal, Canada
    Posts
    46
    So I created the textbox and now it's recording the UserID in the Quality_Table

    What I don't understand is "grab the Name from the table" ? Is it via VBA? Or in the table? What kind of data type should I use for this? I tried text, but I don't have the option of selecting the row source

    Also am I correct to understand that in your code UserName would be the Reviewer Name as inputed in the Reviewer_Table and that the userID is the newly registered UserID from the form? what's the difference between txtUserID and txtUserName ?

    I know many questions but I really appreciate your help and i'm Learning so much right now...

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    i thought you had a table with
    USERID, NAME, etc

    grab the ID, lookup Name using DLOOKUP.
    txtID, a textbox holds the user ID
    txtName, a textbox holds the User Name.

    all this would happen at FORM LOAD event.

  5. #5
    veejay is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Nov 2018
    Location
    Montreal, Canada
    Posts
    46
    Yes I do have a table for UserID and Names of the Reviewer. That table is Reviewers_Table.
    The fields are REV_ID (autonumber), REVIEWER_UserID and REVIEWER_NAME

    In the Quality_Table I have:
    ReviewerID (from the textbox with fOSUserName() ), ReviewerTxt where i'm trying to get the full name stored.

    On my OnLoad event I tried :

    Code:
    Private Sub Form_Load()
        ReviewerTxt = DLookup("[REVIEWER_NAME]", "[Reviewers_Table]", "[REVIEWER_UserID]='" & fOSUserName() & "'")
    End Sub
    and

    Code:
    Private Sub Form_Load()
        ReviewerTxt = DLookup("[REVIEWER_NAME]", "[Reviewers_Table]", "[REVIEWER_UserID]='" &  me.ReviewerTxt & "'")
    End Sub
    But I know i'm doing something wrong...

  6. #6
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    v1 should work, IF ...
    fOSUserName() returns the ID
    and that ID is in the table.

    v2 will not work, since you are using ReviewTxt as source and target.
    youd need 2 txtboxes: 1 for ID (not shown), and 1 for name (ReviewTxt?)

    IDtxt = fOSUserName()
    ReviewerTxt = DLookup("[REVIEWER_NAME]", "[Reviewers_Table]", "[REVIEWER_UserID]='" & me.IDtxt & "'")

  7. #7
    veejay is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Nov 2018
    Location
    Montreal, Canada
    Posts
    46
    Thanks Ranman this worked! I had no idea how to make the dlookup work but this is exactly what I needed.

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

Similar Threads

  1. Replies: 6
    Last Post: 01-03-2021, 05:06 AM
  2. Replies: 11
    Last Post: 08-08-2018, 11:23 AM
  3. Replies: 11
    Last Post: 07-19-2018, 11:13 AM
  4. Restrict Access to Form Based on fOSUserName()
    By ricker090 in forum Programming
    Replies: 1
    Last Post: 11-28-2012, 04:07 PM
  5. Replies: 1
    Last Post: 10-24-2011, 08:01 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