Results 1 to 4 of 4
  1. #1
    yrstruly is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2024
    Posts
    122

    Capture User Name Instead Of User ID

    My user name/i.d consist of this table:

    UserID Username
    1 Armand
    2 Adam Septe.

    It displays the logon user name on my logon form, using this
    Code:
    =[Forms]![frmLogon]![User]
    Code:
    SELECT tblUsers.UserID, tblUsers.Username FROM tblUsers;
    I take this data and display it into a new form/table, in a column called Captured by using this code.


    Code:
    Private Sub Form_BeforeInsert(Cancel As Integer)
        Me!CapturedBy = Forms!frmLogon!User
    End Sub
    It captures the User ID and not the User Name? I want the User Nme to be Captured.

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    perhaps

    Me!CapturedBy = Forms!frmLogon!Username



    All depends on what your form controls are named

  3. #3
    Join Date
    Apr 2017
    Posts
    1,792
    It looks like on form frmLogon you have a combobox named User for selecting the user to log on. With SELECT expression you posted as RowSource. The combo displays (and allows to select) the user name, but the value of combo will be UserID.

    In case you want the logon info inserted into another form, it must be inserted to control linked to UserID in source table in this form. You can have this control as combo with RowSource similar to one in frmLogon - then the combo in this form also displays the user name depending the UserID in tblUsers.

    In case you want to insert the logon info into table directly, then this is a very bad idea. The best policy with access (or any relatonal database) is to hide all tables from users and allow any data entry through forms, procedures, or queries only.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    If you want UserName, why bother with even having a UserID field? Which field is designated as primary key in tblUsers?

    What data type is CapturedBy?

    Either remove UserID from combobox RowSource or reference UserName column by its index.

    Me!CapturedBy = Forms!frmLogon.User.Column(1)
    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.

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

Similar Threads

  1. Replies: 7
    Last Post: 11-27-2023, 02:27 PM
  2. Capture File Name
    By nick243 in forum Programming
    Replies: 7
    Last Post: 02-02-2018, 02:19 PM
  3. Using FileDialog To Capture Selected Name
    By jo15765 in forum Programming
    Replies: 2
    Last Post: 11-16-2017, 06:50 PM
  4. Replies: 13
    Last Post: 05-27-2017, 06:40 AM
  5. capture computer name or person updating database
    By Daniel2000 in forum Programming
    Replies: 1
    Last Post: 07-30-2014, 02:45 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