Want values in form to autofill when a new record is made. Which event?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rsmccli
    New Member
    • Jan 2008
    • 52

    Want values in form to autofill when a new record is made. Which event?

    Access 2002

    Hi, I have a number of comboboxes/textboxes in the header of a form that the user selects values from. These comboboxes/textboxes correspond to controls in a datasheet view subform. When a new record is created in the subform I want these values to automatically write to the new record in the subform.

    Right now I have this autofill procedure running on the AfterInsert event of the subform. It works well, except for the fact that the user has leave the record before the values are updated.

    Example:

    Now: A user creates a new record by entering a SSN in that control. When the user tabs to the next control, no values are autofilled. The user must leave the current record for the autofill to work.

    What I want: A user creates a new record by entering a SSN in that control. When the user tabs to the next control or clicks on another control on the same record, the values are autofilled.

    I have considered some other events, but I definitely would not like access to overwrite anything if, say, the user clicked on a previously created record to change a mistake in the SSN.

    I appreciate any help on this.

    rsmccli
  • PianoMan64
    Recognized Expert Contributor
    • Jan 2008
    • 374

    #2
    Originally posted by rsmccli
    Access 2002

    Hi, I have a number of comboboxes/textboxes in the header of a form that the user selects values from. These comboboxes/textboxes correspond to controls in a datasheet view subform. When a new record is created in the subform I want these values to automatically write to the new record in the subform.

    Right now I have this autofill procedure running on the AfterInsert event of the subform. It works well, except for the fact that the user has leave the record before the values are updated.

    Example:

    Now: A user creates a new record by entering a SSN in that control. When the user tabs to the next control, no values are autofilled. The user must leave the current record for the autofill to work.

    What I want: A user creates a new record by entering a SSN in that control. When the user tabs to the next control or clicks on another control on the same record, the values are autofilled.

    I have considered some other events, but I definitely would not like access to overwrite anything if, say, the user clicked on a previously created record to change a mistake in the SSN.

    I appreciate any help on this.

    rsmccli
    The simplest way to do that is simply bind to the control of the other fields that you wan to auto-populate a DLOOKUP Statement and have it search on the Lost focus event of the SSN field. this way, you can have it populate as many fields as you'd like it to.

    Hope that helps,

    Joe P.

    Comment

    • FishVal
      Recognized Expert Specialist
      • Jun 2007
      • 2656

      #3
      Originally posted by rsmccli
      .....
      Now: A user creates a new record by entering a SSN in that control. When the user tabs to the next control, no values are autofilled. The user must leave the current record for the autofill to work.

      What I want: A user creates a new record by entering a SSN in that control. When the user tabs to the next control or clicks on another control on the same record, the values are autofilled.
      ........
      Hi, there.

      It pretty looks like you you are going to duplicate information which is generally unacceptable practice (Database Normalization and Table structures).
      Form controls may be "autofilled " by using table join as form recordsource. Thus when user fills FK field bound control all controls bound to PK table are being populated to fulfill the join.

      Regards,
      Fish

      Comment

      Working...