Unanswered: populating fields in forms automatically
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.
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
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.