R
raylopez99
FYI, I trust this is "old news" to Access veterans, but as a newbie it
caught me by surprise.
RL
Anybody have this problem when using an old form on a new database
Relationship? I'm pretty sure it's a common problem (hint: don't do
it--always generate a new form if you change the primary keys in a
database schema / architecture).
OK, you'll like this. As fireworks go off outside (I'm ahead of your
time zone), and no wild parties to go to, with a social event looming
tommorrow, very little sleep (this programming stuff is addictive you
know), I spent a good part of two hours trying to get this dang new
schema to work.
I finally figured it out, and it took me a while: Access does indeed
allow compound primary keys, relationships between compound keys, and
the like between tables. No problem whatsoever (I generated from
scratch just such a form, so I know it can be done). However, in my
particular case the problem is this: if you take an old *FORM* (that
is, the Access' front end data entry GUI), that has been customized
for use with artificial non-compound keys (i.e. GUIDs, Long Ints,
etc), apparently, and I'm almost certain of this, the FORMS (not the
tables) contain meta-data on 'indices' and the like, that prevent you
from using the old form with the new compound keys. As proof of this,
I finally saw that the form, when used to create a table having a
subform (child table), was not generating a foreign compound key (one
of the two), and the column for this key was missing. I tried and
correctly specified the "master-child' link for the subform, the
proper generic SQL query for both parent and child subform, and the
like, and still when it came time to enter more than one record, I
notice when I clicked on the raw table a certain compound key
"Stock_ID" for the subform was not being generated (the column was
missing, literally). When I manually inserted it, and fired up the
form again, I got a warming that there was ambiguity in the name of
the stock_id column (since in Access there's an annoying but
convenient habit of not enforcing name distinctions much--you often
have the same name floating around with little if any scope resolution
operator, but I digress). The point of the exercise was to show that
the old form is messed up. I'll cross post this in microsoft.public.
access.formscoding to see if it rings a bell.
I am very confident that I could get the compound primary keys (being
used as foreign keys in a subform table) to work, IF I USED A NEW
FORM. That is the key--no pun intended--using a new form when you
change the keys radically, and you're in form.
ANybody else have this problem? I'm 99% sure this is Access specific
and not in anyway a bug of Access, but a really nasty little
undocumented feature!
BTW, even with the GUID keys in my original schema, I can get the dB
to work fine, except, like I've said, I have to programically check
for duplicate entries--not the end of the world for a small database
like mine.
Happy New Year! I'm going to bed...
RL
caught me by surprise.
RL
Anybody have this problem when using an old form on a new database
Relationship? I'm pretty sure it's a common problem (hint: don't do
it--always generate a new form if you change the primary keys in a
database schema / architecture).
inthis regard.
Tony,
This is the second time around with Ray and compound keys, here in
comp.databases.theory.
A little while ago some of us walked him through setting up a compound key
for a junction table in MS Access. (In spite of the fact that none of us
work much with Access). That worked, according to Ray.
Ray may not have recognized this as another instance of exactly the same
problem.
OK, you'll like this. As fireworks go off outside (I'm ahead of your
time zone), and no wild parties to go to, with a social event looming
tommorrow, very little sleep (this programming stuff is addictive you
know), I spent a good part of two hours trying to get this dang new
schema to work.
I finally figured it out, and it took me a while: Access does indeed
allow compound primary keys, relationships between compound keys, and
the like between tables. No problem whatsoever (I generated from
scratch just such a form, so I know it can be done). However, in my
particular case the problem is this: if you take an old *FORM* (that
is, the Access' front end data entry GUI), that has been customized
for use with artificial non-compound keys (i.e. GUIDs, Long Ints,
etc), apparently, and I'm almost certain of this, the FORMS (not the
tables) contain meta-data on 'indices' and the like, that prevent you
from using the old form with the new compound keys. As proof of this,
I finally saw that the form, when used to create a table having a
subform (child table), was not generating a foreign compound key (one
of the two), and the column for this key was missing. I tried and
correctly specified the "master-child' link for the subform, the
proper generic SQL query for both parent and child subform, and the
like, and still when it came time to enter more than one record, I
notice when I clicked on the raw table a certain compound key
"Stock_ID" for the subform was not being generated (the column was
missing, literally). When I manually inserted it, and fired up the
form again, I got a warming that there was ambiguity in the name of
the stock_id column (since in Access there's an annoying but
convenient habit of not enforcing name distinctions much--you often
have the same name floating around with little if any scope resolution
operator, but I digress). The point of the exercise was to show that
the old form is messed up. I'll cross post this in microsoft.public.
access.formscoding to see if it rings a bell.
I am very confident that I could get the compound primary keys (being
used as foreign keys in a subform table) to work, IF I USED A NEW
FORM. That is the key--no pun intended--using a new form when you
change the keys radically, and you're in form.
ANybody else have this problem? I'm 99% sure this is Access specific
and not in anyway a bug of Access, but a really nasty little
undocumented feature!
Interestingly enough, if you ask Access 97 for help with relationships,
and select the topic "creating a many-to-many relationship" it tells you to
make a junction table with a compound key. This is exactly the advice I
gave, with more detail on how to do it.
But if you turn to some of the books about working with access, or if you
take you cue from the "Northwind" database, you'll get advice to createan
ID field for the junction table, and declare that as the primary key.
Unfortunate for the newbies.
BTW, even with the GUID keys in my original schema, I can get the dB
to work fine, except, like I've said, I have to programically check
for duplicate entries--not the end of the world for a small database
like mine.
Happy New Year! I'm going to bed...
RL