Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2014
    Posts
    2

    Unanswered: form control to get username then store to table

    I have a form called "SCAN INPUT" with a control named "SCAN OPERATOR" that I want to have filled in on the "on open event". Now, I have a table called "EMPLOYEE LIST NEW" that has a fields "LOGIN" and "ID". I also have a table named "BATCH HEADER SHEET" that the form "SCAN INPUT" is it's control source. So, I want code to have Access look at the users login or fOsUserName compare it to the table "EMPLOYEE LIST NEW" and find that login and matching "ID" and put "ID" into form "SCAN INPUT's" control "SCAN OPERATOR" when the form opens. Then have it stored in the table "BATCH HEADER SHEET" so it is one less step that the user has to do. Here is some code that I have messing around with but it doesn't return an data and I get no errors when debugging. Any help would be appreciated.

    Me.SCAN_OPERATOR = DLookup("[ID]", "EMPLOYEE LIST NEW", fOSUserName() & "'")

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Check the syntax for dlookup.
    the third parameter should be a SQL 'where' clause (without the word where).
    Your code isnt. It should be something like "acolumn = '" & fosusername & "'"
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Nov 2014
    Posts
    2
    Forgive me, I am relatively new to coding and vba. I don't think I quite understand your example. I've tried putting your example where I think it should go in the code but to no avail. Could you maybe give me an example of the code using my table names and controls and etc.?

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    replace 'acolumn' with the name of the column in your table which contains the userid

    if you don't understand that then consult the online help for dlookuo
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •