Z
ZBC
Can you build a 3-dimentional table in Access.
I need a look-up table that is based on 3 pieces of information.
I need a look-up table that is based on 3 pieces of information.
lindabob2 said:I have a situation where I have a 'Rate' which is based on three items:
User (001, 002, 003, ... 125)
Year (e.g. 1995, 1996, ... 2004)
PrimaryType (e.g. LIAB, PROP, ... 8 different types)
Given a User, aYear and a PrimaryType, I need to look up a Rate.
Rate (1200, 200, 300, 900, 45000, ... )
Armen said:Hi Linda,
You can create a rate table, say tblRate.
It will have foreign key relationships to the User table and the
PrimaryType table. In addition, it will have a Year field, and a Rate
field.
I also recommend that it have its own Primary Key consisting of an
AutoNumber field.
You can create a unique index on the User, PrimaryType and Year fields
so that no duplicates will be allowed.
On a User form, you can create a subform that shows all the Rates for
that User. It would have the PrimaryType in a combobox, the Year, and
the Rate.
Hope this helps,
lindabob2 said:I'm confused ... will I then have 125 tables?
Can you build a 3-dimentional table in Access.
I need a look-up table that is based on 3 pieces of information.
After reading your response, I am getting the feeling that a query might
be able to deal with this ... ???
I'm confused ... will I then have 125 tables?
John said:well... yes.
If you want to look up a rate given three criteria, create a query
with three criteria. It's not really "three dimensional" - it's just
that you need three inputs to locate a record.
You'll just need a table with four fields (your three criteria fields
and the corresponding rate), with 11,000 rows. Not a very big table
actually. If you want to think of it as an Array, you can; but it's
simply a table that you're searching, in Access jargon!
John said:You won't have 125 Access tables, no. But do you now have separate "rate
cards" for each of your 125 users?
Do you want to be able to set the
rate for each PrimaryType for each Year for each User quite
independently of the rate for every other User? If so, 125 Users times 8
PrimaryTypes means you have to store 1000 separate rates for each Year.
Looking things up based on three fields in a table containing thousands
or tens of thousands of records is absolutely no problem for Access. The
table would be like this:
tblRates
User - foreign key into Users table
Year
PrimaryType
Rate
(Primary key of tblRates contains the 3 fields
User, Year and PrimaryType).
But it seems unlikely that you really need to have a separate rate
structure for every user. In most situations with this many users there
would be some sort of categorisation of users and the rates would depend
on the category the user was placed in. So there might be a
tblCategories with categories such as
Senior Partner
Partner
Junior Partner
Senior Consultant
Consultant
Junior Consultant
Research Consultant
Junior Research Consultant
Office Cat
and
tblUsersCategories
User - foreign key into Users table
Category - foreign key into tblCategories
and then tblRates would be
Category - FK into tblCategories
Year
PrimaryType
Rate
and you would use a query joining tblRates and tblUsersCategories to
retrieve the rate for a particular User, PrimaryType and Year.
Does this make things any clearer? (Another possibility is that the
rates are based on formulas of some kind; if so it's usually best to
have Access store the underlying values and formula(s) and calculate
each actual rate "on the fly" whenever it's needed.)
[snip]
Only you guys (and gals)! ... If it were not for these newgroups, IArmen said:I'm confused ... will I then have 125 tables?
Armen Stein wrote:
Hi Linda,
No. I've mentioned only a few tables. They might look something like
this:
[tblUser]
UserKey (AutoNumber primary key)
UserFirstName
UserLastName
TypeKey (Long Integer foreign key)
[tblType]
TypeKey (AutoNumber primary key)
TypeName
[tblRate]
RateKey (AutoNumber primary key)
UserKey (Long Integer foreign key)
TypeKey (Long Integer foreign key)
RateYear
RateAmount
The tblUser table contains a record for each User.
The tblType table contains one record for each Type (you mentioned that
there are about 8 of them).
The tblRate table contains one record for each *combination* of User,
Type and Year. For example, User A for LIAB in 2001 is in one record,
while User B for PROP in 2002 is in another record.
Also, this design would allow you to track rates for multiple types of
coverage for the same User - for example, a User may have both LIAB and
PROP, each in multiple years.
This is a relatively complex design to code in forms and reports. Do
you know a more experienced developer that can help you out?
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.