On Mon, 1 Jan 2007 11:15:00 -0800, Crissi
<(E-Mail Removed)> wrote:
>I am working on a new database for '07 and I wanted some of my fields to
>prefill for accuracy.
First off... storing data, such as a date or a year, in a Tablename is
a bad idea. Storing it in a Database name is an even WORSE idea. You
really should consider having an ongoing database with a date field,
or an ID field, or an ItemYear field that can let you select the
information for a given year using a query. This will let you much
more easily select historic data, compare year to year, and so on.
>Please, I've heard that the task is simple but I can't find how to go about
>it with the resources I have (which are pretty limited!)
>
>This is the information types I am working with:
>
>Each of our customers has an account number and several job numbers-which
>are actually just IDs for the locations of each branch of that customer.
>
>For example, customer number 1 has branches number 1, 2, and 3.
>Customer number 2 also has 3 branches.
>The branches are numbered simply starting from 1 inside each customer's
>account.
You then certainly need two tables: a table of Customers, related one
to many to a table of Branches. The Customers table would contain
information relevant to the customer - AccountNumber, CustomerName,
and so on; the Branch table would contain only a CustomerID linking to
the customers table, a BranchNumber (1, 2, 3...), and any information
that you need to record about the branch itself, such as the address.
>What I would like to accomplish is, by typing in the account number, the
>customer's name automatically prefills in another field. Then I need my form
>to recoginze that THIS customer has 3 branches-provide a drop down box from
>which I can choose the corresponding branch. Once I choose the corresponding
>branch, then the address to that branch will prefill in another field.
You certainly DO NOT want to copy the customer name, or the branch
address into any other table. They should be stored, once and once
only, in their respective table.
You can DISPLAY the customer name in several ways; one simple one
would be to use a Combo Box on your form to select the account number.
Include the customer name in the combo's row source query, and put a
textbox on the form with a control source like
=comboboxname.Column(n)
where n is the zero based index of the CustomerName field in the
combo's query.
You can create a dependent branch combo box by basing it on a Query
which references the account number field. Use a query like
SELECT BranchNumber, BranchAddress
FROM Branches
WHERE Branches.AccountNo = Forms!YourFormName!txtAccountNo
ORDER BY BranchNumber;
This does need one line of VBA code: in the account number combo,
you'll need to Requery the branch combo.
You'll do the same trick with another unbound textbox to display the
address.
In addition - or instead - you could use a Form based on the accounts
table, with a continuous Subform based on the Branches table, to show
all the branches for that customer.
>I know this has to be possible because I was told that this kind of task was
>just barely scratching the surface of Access.
>
>I am running 2003 and again would appreciate any information possible!
If you could post some more details of your table structure and your
form (or forms), we'll be glad to help.
John W. Vinson[MVP]
|