Enter Data into a field automatically depending on data entered in previous field

J

JackieM

I am working in Access forms. I have a field that allows data entry
operators to pick from a list of towns. In another field on the form,
I would like the town's corresponding number to be filled in
automatically once the previous town name field is filled in. How can
I do this?
 
D

Duane Hookom

You don't state whether the "another field" is a bound or unbound text box.
If the town name and the town number are always related one-to-one then
there is no reason to store both values.

I assume the town name is selected with a combo box and the town number and
town name are both fields available in the Row Source query of the combo
box. Make sure the town number is in the select statement of the row source.
Then set the control source of the town number text box to something like:
=cboTownNumber.Column(x)
"x" is the column number from the Town Number combo box where column
numbering begins with 0.
 
J

JackieM

Actually, I did not explain my situation very well. I have a bound
combo box for the town name field ("Town") in a table I'll call
"Table1" that uses a query ("qryTownList") as the Row Source in the
combo box. (This query also has the town number.) Then, on the same
form and in the same table, I have a field called "Parcel_ID". The
first three digits of Parcel_ID is the town number. I want to
automatically populate the first three digits of this Parcel_ID field
before the record is updated, but after the "Town" field value is
entered, to insure that the Parcel_ID field has the correct town number
for the town name. In this way, the data entry person only has to
enter the remaining digits into the Parcel_ID field; the first three
are already entered. Any help would be appreciated.
 
D

Duane Hookom

You could then use code in the After Update event of the combo box. It might
look something like:

If Len(Me.Parcel_ID & "") <= 3 Then
Me.Parcel_ID = Me.Town.Column(x)
End If

This assumes your combo box is named "Town", your Parcel_ID text box is
named "Parcel_ID", and you substitue the correct column number for "x".
 

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

Top