Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Posts
    16

    Unanswered: populating fields in forms automatically

    Hi,

    I am making a form in Access. I need it to populate certain fields automatically when other fields are entered. For example if I enter "bob" in first name I want it to enter "davids" in the last name field. I ofcourse have a table with first and last names.

    I tried using subforms but it shows up as a subform on the main view too and I would like it to show up as a regular field in the form.

    Thanks for your help.

  2. #2
    Join Date
    Sep 2001
    Location
    Chicago, Illinois, USA
    Posts
    601
    On the AfterUpdate of the one entry field, do a dlookup to the table with this first entry field's value as the criteria. Then, simply, assign the results to the second field.

  3. #3
    Join Date
    Mar 2004
    Posts
    16
    Hi,

    I did that and my code is
    Dim varDealerNo, varDealerName, varName
    varDealerNo = DLookup("DealerNo", "Registration Master", "Pin =[PIN]")
    varDealerName = DLookup("DealerName", "Registration Master", "Pin =[PIN]")
    varName = DLookup("Name", "Registration Master", "Pin =[PIN]")
    If (Not IsNull(varDealerNo)) Then Form_Main![DealerNo] = varDealerNo
    If (Not IsNull(varDealerName)) Then Form_Main![DealerName] = varDealerName
    If (Not IsNull(varName)) Then Form_Main![Name] = varName
    End Sub

    But for some reason when i do that it always populates the rest of the fields(DealerName,DealerNo,Name) with the same record. Has it somehow locked onto that one record? I cant see what I am doing wrong!

    Thanks for your help

    Originally posted by PracticalProgram
    On the AfterUpdate of the one entry field, do a dlookup to the table with this first entry field's value as the criteria. Then, simply, assign the results to the second field.

Posting Permissions

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