Easy Fill In but I don't get it

L

LindaC

I have a field Department in my tblArchive which is a drop down in my form.
If I select Accounting as the field I would like a Cost Centre field to be
automatically filled in with the corresponding number. Not sure how this
should be set up. Please and thank you.
 
A

Al Campagna

Linda,
Add the CostCentre field to your combo... (ex. cboDepartment)
I'd set it up like this
DeptID Dept CostCentre
12 Accounting 123-526
22 Finance 714-524 etc...

Combo setup...
ControlSource = DeptID
NoOfColumns = 3
ColumnWidths = 0" ; 1.5" ; 1"
ListWidth = 2.5"
LimitToList = Yes

What this does is... the user selects a department by name (the easiest method), the combo
displays the Dept name, but...the combo really stores the DeptID in the "bound" DeptID
field. That takes care of the selection...

Using the AfterUpdate event of the combo....
Me.CostCentre = cboDepartment.Column(2)
(combo cols are number left to right... 0,1,2,3, etc...)

But... you really don't need to save the CostCentre, unless CostCentre numbers might
ever change. If it's always the same, you can just display the CostCentre on the form,
and re-associate Dept to CostCentre in any subsequent form, query, and report... via the
captured DeptID.
In that case, just an unbound calculated field for CostCentre with a ControlSource
of...
=cboDepartment.Column(2)
will always "display" the correct CostCentre.

If you're in doubt as to which method to use... use the first method.
-
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."
 

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