Based on entered field value autofill other fields in the form RRS feed

  • Question

  • I have a form frmTimeEntry. The record source for this form is tblStaff.

    When this form is opened a default value appears in the field txtUserName (it comes from Login form).

    I need to autofill 2 other fields (e.g. txtUserPosition, txtUserDepartment) based on what appears in txtUserName (all values are in tblStaff)

    I can do it using DLookup but I was told it is not a good idea. Any other ways?

    Thursday, February 2, 2017 3:44 PM


  • Hi,

    Why did they say it's not a good idea? What is the form's purpose? How come frmTimeEntry's record source is tblStaff rather than tblTimeEntries?

    Remember, if you're trying to store a foreign key in another table, you just want the ID field from the parent table and don't need to "copy" additional information because you can always just "display" the related data any time you need it and using DLookup() would be one way to do it.

    Just my 2 cents...

    • Marked as answer by Oleg.bv Thursday, February 2, 2017 3:58 PM
    • Edited by .theDBguy Thursday, February 2, 2017 4:07 PM
    Thursday, February 2, 2017 3:54 PM