automatic feild insertion

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

how do you have a field fill information in form an existing tabel
autmaitcally when a previous field is filled? Example I pick a last name for
a combo box and the first name and phone number will fill automatically. I
can do it in a form but it will not write to the table
 
It should not write to the table. You only store that data in one table.
When you add related data to another table, you only store the key, not the
data.

In other words, if you have a transaction table and you fill in the "person
ID", that is all you need in that table. You don't want the person's name
and phone number stored in the transaction table. What happens if they
change phone numbers? Then the data is wrong.

For more info, look at the northwind database that ships with Access. Go
try to add an invoice and notice how it handles it when you select a
customer. It fills in the address data on the form, but that is not saved
back to the invoice table.
 
If you are writing more than the ID value of that person to another table,
you are probably writing too much data. Normalization rules forbid writing
anything more than a key from one table to another.

To answer your question on how, you push the data in the combo's AfterUpdate
event:

Sub MyCombo_AfterUpdate()
Me.txtFirstName = Me.MyCombo.Column(2)
Me.txtPhone = Me.MyCombo.Column(3)
End Sub

Where Column 2 (actually the 3rd column) and Column 3 (actually the 4th
column) of the combo box contain the first name and phone data.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Combo Box Values 5
field duplication in tables 9
Combo Box Problems 1
tables 3
Manually storing Data to a field 8
Row Source 8
Auto fill of fields 4
How to calculate the age in a particular month? 0

Back
Top