Getting a Field to popluate with table info

  • Thread starter Thread starter Steel
  • Start date Start date
S

Steel

Guest
Hi..I need to know how on a form to get a field to populate the other fields base on the value you input into that field.. Example: I want to be able to have my field named "Employee Name" to automatically update once I have input the Employee Number in the previous field. This is a small example but eventually I want to input the employee name and all other info about that employee to populate the various fields based upon that employee number.
 
So the form you are using is NOT based on the table that contains this information. That's fine. What you will need to do first is create a query that draws together all the information you will want to populate the form fields (the other table). I am assuming that you want to store that information. If not, use Dlookup to show the name, etc.

Put a combobox on your form based off the query you created.
On you form, show the fields you want populated.
On the AfterUpdate event of the combobox, put this code.

Me.NameField = ComboBoxName.Column(1)
Me.AddressField = ComboBoxName.Column(2)
etc.

That is an example. I don't know what your fields are named.

Anyway, the columns that are in your combo begin with 0 and then 1,2,3...

If you would rather use Dlookup, post back.
 
If you have your database properly "Nomalized" and you have your "Relational Joins" also correct, you only need to add the table that contains the EmployeeInfo into the Recordset query that the form is based on. All needed info for the employee will populate your controls as soon as the ID from the table is identified through the Relational Joins. "You will not need an event procedure to do this".

The info from the EmployeeInfo table should not be stored in the main table in this process. All that should be stored in the main table is the Record ID from the EmployeeInfo table. Then this info can be produced "dynamically" when needed again through the use of the Relational Joins as explained above.

HTH
RDH

[This message has been edited by R. Hicks (edited 09-08-2001).]
 
Along the same lines, I've got similar things in my forms, and using this info I was able to get associated text boxes to display the proper information when a combo box was changed. My question however is this; How do you clear the contents of those text boxes when you exit that record and proceed to the next record? My text boxes are unbound, and I'm using them exclusively for informational purposes. They contain calculated values based on the information entered by the user, as a check etc as they're entering the data. As it stands however, the data in the text boxes is carried over to the next record, which I don't want to happen, and I can't find a "Clear" command that could be put in. Any suggestions?

Kyle B.
 

Users who are viewing this thread

Back
Top Bottom