Re: How to enforce subtypes/supertypes in Access 2000?
- From: "tina" <nospam@xxxxxxxxxxx>
- Date: Mon, 07 Aug 2006 00:36:29 GMT
comments inline.
"Bob" <fakeemail@xxxxxxxxx> wrote in message
news:44d666e6$0$21306$5a62ac22@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Tina,
I did have a few extra questions.
Firstly, in what way might you have otherwise structured the relevant
contact information? I'm a novice, so I'm open to ideas.
sorry, didn't mean to be a tease. as i said, since i haven't analyzed the
business process, i couldn't state an alternate tables/relationships design
with confidence. i tend to stay very much "inside the box" on
table/relationship design, and have trouble with the more unusual
configurations that are necessary to model some real-world relationships. i
wish we could get Tim Ferguson into this thread; he's about the best i've
seen in these newsgroups re solving non-standard relationships and
explaining the configurations in a way that is easy to understand.
the
Secondly, without complicating things too much, I should mention that my
table structure includes two additional tables:
tblClientFiles - a junction table with ClientID and FileID specified as
primary key; andtblClients.FileID)
tblFiles - which, amongst other things, has the following three fields:
FileID (pk - autonumber) (with a 1:Many relationship with
FileNumber (txt - alphanumeric content (needs to be changed from time to
time, so not used as pk)
DateOpened - date/time
DateCompleted - date/time
hmm, i do have to wonder here about your relationships. if tblFiles is
related to tblClients via a junction table called tblClientFiles, then why
is tblFiles also directly linked to tblClients? use of a junction table
essentially says that on client may be related to many files, and one file
may be related to many clients - a many-to-many relationship that the
junction table resolves into two one-to-many relationships. but a direct
relationship says that one client may be related to many files, but each
file is related to only one client - which is a straightforward one-to-many
relationship. so we have an apparent contradiction here.
times.
To be honest, I struggle with insert/update commmands at the best of
It seems even more complicated once you start normalising and multiplyingof
the tables.
Anyway, my queries are:
(a) based on the table structure I have outlined, how would you construct
the sql strings to select, insert and delete a record into tblFiles?; and
(b) how would you construct the same strings where the "client" consists
two persons (say a husband and a wife) who each have their own record inat
tblContacts and tblClients?
By the way, someone else was pretty much asking the same question I asked
the outset (about ensuring that only one of the subtype tables wasupdated)
- see http://www.dbforums.com/archive/index.php/t-1053752.html. One ofthe
responses to that post was as follows:my
Because you do not specify what is in the "generic table" [equivalent to
tblContacts], it is difficultyou
to offer specific suggestions. I can suggest that in the generic table,
identify the type of contact [equivalent to my tblContactType], createyour
query linking to both, and use andata
outer join in order to allow one of the related tables to return a Null
entry. By outer join, I mean rightclicking on the join line between the
sources in the Query, and choosing "All records from Contacts [ie my
tblContacts] and only those
that match from People [ie my tblIndividuals]" and "All records from
Contacts and only those that
match from Companies [ie my tblOrganisations]".
I don't quite understand what this means. Does it mean that in order to
perform select/insert/update commands programatically on, say, tblFiles or
tblOrganisations, I will need to do a whole lot of "outer joins"? If so,
what would one look like in my case?
sorry, hon, the above is all way too theoretical for me; i'm very much a
nuts-and-bolts person. if you can lay out a specific scenario, explaining
what the setup is and what you're trying to do in this situation, i'll work
on a solution with you. in any event, i can't help at all until we iron out
the issue of the real-world relationship between tblFiles and tblClients.
hth
chooses
Regard
Bob
"Bob" <fakeemail@xxxxxxxxx> wrote in message
news:44d65939$0$21282$5a62ac22@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Thanks Tina,
I'll give that go.
Regards
Bob
"tina" <nospam@xxxxxxxxxxx> wrote in message
news:5VqBg.221185$mF2.88072@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
btw, suggest you use one subform in your main form. when the user
propertiesan
option in the main form's combo box control, then use VBA to set the
subform's SourceObject, LinkChildFields, and LinkMasterFields
afor
the appropriate subform object. going from memory, you may need to put
that[SubformControlName].Form.Requery command at the end of the code, so
ratherthe correct records will populate the chosen subform.
hth
"tina" <nospam@xxxxxxxxxxx> wrote in message
news:1oqBg.221099$mF2.203409@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hmm, okay. i don't know that i'd set up the tables quite that way, but
you've analyzed the business process and i haven't - so i also don't
know
that any alternate suggestions i made would actually be "better",
arethan simply different, or even not as good.
so to get back to your original question: AFAIK, table constraints
canceluser
in SQL server, and perhaps other database types; but are not availableDCount()
in
Access. so you'll need to enforce the business rule at the form level.
in
the main form, you can set up some code on the combo box control's
BeforeUpdate event to check the "other" subtype table for a record
containing the current Contact record's primary key value (a simple
function would handle that easily). if it exists, you can either
subform -the
control's BeforeUpdate event, with a message box to tell the user todelete
the current subform record before adding a record to the other
box,or
tell the user that if they choose the alternate value in the combo
choosethe
record in the current subform will be deleted, and asking them to
record,to
continue or cancel. if they cancel, then just cancel the BeforeUpdateevent;
if they continue, then automatically delete the current subform
sole-proprietorships,and
then switch to the other subform.I
hth
"Bob" <fakeemail@xxxxxxxxx> wrote in message
news:44d6238f$0$21313$5a62ac22@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Thanks for your interest Tina,business)
My full table structure is as follows:
tblContacts:
ContactID (pk)
ContactType (fk)
Address1
Address2
City
State
PostCode
PostalAddress1
PostalAddress2
PostalCity
PostalState
PostalPostCode
Tel
Fax
Mob
tblIndividuals:
IndivID (pk)
ContactID (fk)
Title
FirstName
MiddleNames
LastName
Suffix
EmployerID (fk) (links back to tblContacts.ContactID (1:Many))
EmpDirectPhn
EmpDirectFax
EmpEmail
tblOrganisations:
OrgID (pk)
ContactID (fk)
OrgName
TradingName
IsACompany (yes/no)
ACN (Australian Company Number)
ABN (Australian Business Number)
Website
tblContactType
ContactTypeID (pk)
ContactType ("Indiv" or "Org")
As you can see, tblContacts lists the location (ie residential or
addresses, postal addresses and (residential or business)telecommunication
details for all contacts. The table tblIndividuals segregates theindividual's
individual-specific biographical information together with the
work details. The EmployerID links back to the ContactID field in
tblContacts because we often end up acting for employees of existing
corporate clients or for muliple employees of non-client
organisations.
segregate the Organisation details so that I can record details for
all
businesses (incorporated and unincorporated (ie
relevantpartnerships, associations, churches etc)) that simply aren't
Individualsto
individuals. It also enables me to set up a separate table(tblOrgContacts)
to identify individual contacts for the organisation entities (a
1:Many
relationship is established between the two tables based on
tblOrganisations.OrgID (pk) and tblOrgContacts.ContactID (fk)). For
our
purposes, we do not require any contacts to be linked with
whichas
myopposed to Organisations.
The above tables essentially constitute the whole set of "contacts"
for
employer's business; tblContacts is then linked with tblClients
youindividualsidentifies those contacts that are in fact clients:
tlbClients:
ClientID (pk) (autonumber)
ContactID (fk) (related to tblContacts.ContactID) (1:1 relationship)
ReferrerID (fk) (related to tblContacts.ContactID) (1:Many
relationship)
Regards
Bob
"tina" <nospam@xxxxxxxxxxx> wrote in message
news:bCnBg.220675$mF2.29695@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
my first thought is: do you really need to to separate the
records and organizations records into different tables? suggest
apost
perhapsall the fields in each of those two tables so we can review them;
we
can help you combine the two tables into one, with the addition of
news:44d5b441$0$21304$5a62ac22@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxsingle
field specifying either "individual" or "organization".
hth
"Bob" <fakeemail@xxxxxxxxx> wrote in message
AtandHi folks,(simplified)
I am creating a client database in MS Access with the following
table structure:
tblContacts:
ContactID (pk - autonumber)
ContactType (fk) (from tblContactTypes)
ContactDetails (text)
tblIndividuals
IndivID (pk - autonumber)
ContactID (fk) (from tblContacts)
IndivDetails (txt)
tblOrganisations
OrgID (pk - autonumber)
ContactID (fk) (from tblContacts)
OrgDetails (txt)
tblContactTypes (serves as a lookup table)
tblContactTypeID (pk - autonumber)
tblContactType (txt - contains values "Indiv" or "Org")
There is a 1:1 relationship between the ContactID (pk) in
tblContacts
the ContactID (fks) in tblIndividuals and tbleOrganisations.
I have created a form in MS Access for entering client details.
combo-box,the
orpositionedmoment, I have two subforms - frmIndiv and frmOrg - which are
on
my main entry form.
The form contains a combo-box from which the user can select
"Indiv"
"Org" as the ContactType. Depending on the value in the
ContactTypeone
or
other of the two subforms will become visible.
At the moment, the user selects - say - "Indiv" as the
inand
happens,proceeds to enter details for this type of Contact. When this
want.thethe
ContactID for the current record in tblContacts table is mirrored
in
ContactID foreign key in the tblIndividuals table. This is what I
The problem is that once the user is finished (and whilst still
frmOrg.the
same
record in the tblContacts table), the user can select "Org" from
the
combo-box and be provided with a empty copy of the sub-form
foreignIf
the
user proceeds to enter data on the sub-form, the ContactID
sokey
inin
andthe frmOrg will also mirror the ContactID in tblContacts.
This results in a record in both of my subtype tables
(tblIndividuals
tblOrganisations) having a record which points to the same
ContactID
recordthe
supertype table (tblContacts).
How can I prevent this from happening? - ie make sure that each
inwhich
the subtype tables points to a record in the supertype table for
noit
subtype record has already been created? (That's a mouthful - I
hope
makes sense). I've seen some references to "check constraints" on
the
internet which I believe might help achieve my objective. But -
far
asno
(II
am aware - I can't impose check constraints on fields in Access
2000.
have seen a suggestion that this might be achieved by using ADO,
but
code
example was given).
Any pointers would be appreciated.
Please note, I am a complete novice at this.
TIA
Bob
.
- Follow-Ups:
- References:
- How to enforce subtypes/supertypes in Access 2000?
- From: Bob
- Re: How to enforce subtypes/supertypes in Access 2000?
- From: tina
- Re: How to enforce subtypes/supertypes in Access 2000?
- From: Bob
- Re: How to enforce subtypes/supertypes in Access 2000?
- From: tina
- Re: How to enforce subtypes/supertypes in Access 2000?
- From: tina
- Re: How to enforce subtypes/supertypes in Access 2000?
- From: Bob
- Re: How to enforce subtypes/supertypes in Access 2000?
- From: Bob
- How to enforce subtypes/supertypes in Access 2000?
- Prev by Date: Re: How to enforce subtypes/supertypes in Access 2000?
- Next by Date: Re: formatting individual text
- Previous by thread: Re: How to enforce subtypes/supertypes in Access 2000?
- Next by thread: Re: How to enforce subtypes/supertypes in Access 2000?
- Index(es):
Relevant Pages
|
Loading