PC Review


Reply
Thread Tools Rate Thread

Building Composit key on the fly, Boy Scout Data Base

 
 
Dick Patton
Guest
Posts: n/a
 
      26th Mar 2010
Hi all,

I have two tables each is unique. One is the "Merit Badge" tabel the other
"person Id" (name address info) tabel, there is a link tabel "MB-ID_link".
This intent is to connect mert badges with the IDs of Councelors. That works
great, however, i find that i can add duplicate records (same Person, same
Merit badge many times) this is not good.

I created a "check_key" field in the Link tabel which i defined as primary
key. This will stop duplicates from being entered without a lot of code.
The problem is i am not sure how to populate the new key. I know of no way
of concatination in access or where to place the code, but it must be built
before update.

So - I tried: Check_key = trim([MB_code) & [Person_ID]) in the event calle
"before UPdate" that did not work!

It seems like such a simple thig to do!

Help

Dick
 
Reply With Quote
 
 
 
 
John W. Vinson
Guest
Posts: n/a
 
      26th Mar 2010
On Fri, 26 Mar 2010 13:40:01 -0700, Dick Patton
<(E-Mail Removed)> wrote:

>Hi all,
>
>I have two tables each is unique. One is the "Merit Badge" tabel the other
>"person Id" (name address info) tabel, there is a link tabel "MB-ID_link".
>This intent is to connect mert badges with the IDs of Councelors. That works
>great, however, i find that i can add duplicate records (same Person, same
>Merit badge many times) this is not good.
>
>I created a "check_key" field in the Link tabel which i defined as primary
>key. This will stop duplicates from being entered without a lot of code.
>The problem is i am not sure how to populate the new key. I know of no way
>of concatination in access or where to place the code, but it must be built
>before update.
>
>So - I tried: Check_key = trim([MB_code) & [Person_ID]) in the event calle
>"before UPdate" that did not work!
>
>It seems like such a simple thig to do!


It is simpler than you're making it, and you certainly do not need to
construct a new field to do it.

Instead, open the link table in design view. ctrl-click the Person ID and the
Merit Bage fields so they're both selected (darkened). Click the key icon to
make these two fields a joint, two-field Primary Key; this will require that
every record be unique for the combination, even though each field by itself
can have duplicates.

If you already have a primary key, you can instead use the Indexes tool on the
toolbar to create a unique twofield index. Put some distinctive index name in
the left column, and the person ID next to it; put the MB Code in the second
column just below the person ID, and check the "unique" checkbox.
--

John W. Vinson [MVP]
 
Reply With Quote
 
Jeff Boyce
Guest
Posts: n/a
 
      26th Mar 2010
Dick

I'm not sure I understand your situation, what it is that you are trying to
use Access to do.

One possible scenario for what you've described might be:

* You have people
* You have merit badges
* You have people-with-meritbadge(s)

If that's your situation, I think you need to be looking at three tables
instead of two.

More information, please...

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

"Dick Patton" <(E-Mail Removed)> wrote in message
news:C28AAB89-6849-45D1-9C45-(E-Mail Removed)...
> Hi all,
>
> I have two tables each is unique. One is the "Merit Badge" tabel the
> other
> "person Id" (name address info) tabel, there is a link tabel "MB-ID_link".
> This intent is to connect mert badges with the IDs of Councelors. That
> works
> great, however, i find that i can add duplicate records (same Person, same
> Merit badge many times) this is not good.
>
> I created a "check_key" field in the Link tabel which i defined as primary
> key. This will stop duplicates from being entered without a lot of code.
> The problem is i am not sure how to populate the new key. I know of no
> way
> of concatination in access or where to place the code, but it must be
> built
> before update.
>
> So - I tried: Check_key = trim([MB_code) & [Person_ID]) in the event
> calle
> "before UPdate" that did not work!
>
> It seems like such a simple thig to do!
>
> Help
>
> Dick



 
Reply With Quote
 
Steve
Guest
Posts: n/a
 
      26th Mar 2010
When entering data into a database, you have to rely on the data entry
person at some point!

You need these tables:
TblPerson
PersonID
<person fields>

TblMeritBadge
MeritBadgeID
MeritBadgeName

TblMeritBadgeAward
MeritBadgeAwardID
PersonID
MeritBadgeID
DateMeritBadgeAwarded

You need a form/subform for entering data. Base the main form on TblPerson.
Base the subform on TblMeritBadgeAward. Set the LinkMaster and LinkChild
properties to PersonID. Use a combobox in the subform to enter MeritBadgeID.
Your form/subform will display a single person and a list of merit badges
awarded to that person. You can sort the merit badges in alphabetical order.
Now all you need do is rely on the data entery person not to enter a
duplicate merit badge for any person.

Steve
(E-Mail Removed)


"Dick Patton" <(E-Mail Removed)> wrote in message
news:C28AAB89-6849-45D1-9C45-(E-Mail Removed)...
> Hi all,
>
> I have two tables each is unique. One is the "Merit Badge" tabel the
> other
> "person Id" (name address info) tabel, there is a link tabel "MB-ID_link".
> This intent is to connect mert badges with the IDs of Councelors. That
> works
> great, however, i find that i can add duplicate records (same Person, same
> Merit badge many times) this is not good.
>
> I created a "check_key" field in the Link tabel which i defined as primary
> key. This will stop duplicates from being entered without a lot of code.
> The problem is i am not sure how to populate the new key. I know of no
> way
> of concatination in access or where to place the code, but it must be
> built
> before update.
>
> So - I tried: Check_key = trim([MB_code) & [Person_ID]) in the event
> calle
> "before UPdate" that did not work!
>
> It seems like such a simple thig to do!
>
> Help
>
> Dick



 
Reply With Quote
 
John... Visio MVP
Guest
Posts: n/a
 
      27th Mar 2010
"Steve" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> You need a form/subform for entering data. Base the main form on
> TblPerson. Base the subform on TblMeritBadgeAward. Set the LinkMaster and
> LinkChild properties to PersonID. Use a combobox in the subform to enter
> MeritBadgeID. Your form/subform will display a single person and a list of
> merit badges awarded to that person. You can sort the merit badges in
> alphabetical order. Now all you need do is rely on the data entery person
> not to enter a duplicate merit badge for any person.
>
> Steve



You forgot the part about chastising the poster for his table design and
that only you can help him --- for a fee.

John...

 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      27th Mar 2010
On Fri, 26 Mar 2010 19:27:58 -0400, "Steve" <(E-Mail Removed)> wrote:

>Now all you need do is rely on the data entery person not to enter a
>duplicate merit badge for any person.


Or you can use Access as it is designed... with a unique index on the two
fields. You're not enhancing your reputation any, Steve.
--

John W. Vinson [MVP]
 
Reply With Quote
 
Dick Patton
Guest
Posts: n/a
 
      28th Mar 2010
John,

Yes, Yes, that worked perfectly. It was simpler than i thought.

Rule: Use the DBMS to do the work when ever you can!

Thank loads....

"John W. Vinson" wrote:

> On Fri, 26 Mar 2010 13:40:01 -0700, Dick Patton
> <(E-Mail Removed)> wrote:
>
> >Hi all,
> >
> >I have two tables each is unique. One is the "Merit Badge" tabel the other
> >"person Id" (name address info) tabel, there is a link tabel "MB-ID_link".
> >This intent is to connect mert badges with the IDs of Councelors. That works
> >great, however, i find that i can add duplicate records (same Person, same
> >Merit badge many times) this is not good.
> >
> >I created a "check_key" field in the Link tabel which i defined as primary
> >key. This will stop duplicates from being entered without a lot of code.
> >The problem is i am not sure how to populate the new key. I know of no way
> >of concatination in access or where to place the code, but it must be built
> >before update.
> >
> >So - I tried: Check_key = trim([MB_code) & [Person_ID]) in the event calle
> >"before UPdate" that did not work!
> >
> >It seems like such a simple thig to do!

>
> It is simpler than you're making it, and you certainly do not need to
> construct a new field to do it.
>
> Instead, open the link table in design view. ctrl-click the Person ID and the
> Merit Bage fields so they're both selected (darkened). Click the key icon to
> make these two fields a joint, two-field Primary Key; this will require that
> every record be unique for the combination, even though each field by itself
> can have duplicates.
>
> If you already have a primary key, you can instead use the Indexes tool on the
> toolbar to create a unique twofield index. Put some distinctive index name in
> the left column, and the person ID next to it; put the MB Code in the second
> column just below the person ID, and check the "unique" checkbox.
> --
>
> John W. Vinson [MVP]
> .
>

 
Reply With Quote
 
Dick Patton
Guest
Posts: n/a
 
      28th Mar 2010
Thank you, Jeff i am sorry i did not communicate well. There are 3 table and
MB-Link forms the retionship between the merit badge and the councilor but
both are one to many relationships so i neede3d a way to store only those
that are unique combinations and John's suggestion worked perfectly. I just
wish i could trap the error and give a used friendly message like "this
record already exists".

"Jeff Boyce" wrote:

> Dick
>
> I'm not sure I understand your situation, what it is that you are trying to
> use Access to do.
>
> One possible scenario for what you've described might be:
>
> * You have people
> * You have merit badges
> * You have people-with-meritbadge(s)
>
> If that's your situation, I think you need to be looking at three tables
> instead of two.
>
> More information, please...
>
> Regards
>
> Jeff Boyce
> Microsoft Access MVP
>
> --
> Disclaimer: This author may have received products and services mentioned
> in this post. Mention and/or description of a product or service herein
> does not constitute endorsement thereof.
>
> Any code or pseudocode included in this post is offered "as is", with no
> guarantee as to suitability.
>
> You can thank the FTC of the USA for making this disclaimer
> possible/necessary.
>
> "Dick Patton" <(E-Mail Removed)> wrote in message
> news:C28AAB89-6849-45D1-9C45-(E-Mail Removed)...
> > Hi all,
> >
> > I have two tables each is unique. One is the "Merit Badge" tabel the
> > other
> > "person Id" (name address info) tabel, there is a link tabel "MB-ID_link".
> > This intent is to connect mert badges with the IDs of Councelors. That
> > works
> > great, however, i find that i can add duplicate records (same Person, same
> > Merit badge many times) this is not good.
> >
> > I created a "check_key" field in the Link tabel which i defined as primary
> > key. This will stop duplicates from being entered without a lot of code.
> > The problem is i am not sure how to populate the new key. I know of no
> > way
> > of concatination in access or where to place the code, but it must be
> > built
> > before update.
> >
> > So - I tried: Check_key = trim([MB_code) & [Person_ID]) in the event
> > calle
> > "before UPdate" that did not work!
> >
> > It seems like such a simple thig to do!
> >
> > Help
> >
> > Dick

>
>
> .
>

 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      29th Mar 2010
On Sun, 28 Mar 2010 14:36:01 -0700, Dick Patton
<(E-Mail Removed)> wrote:

>Rule: Use the DBMS to do the work when ever you can!


<g> You've sure got that right!!!
--

John W. Vinson [MVP]
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP BUILDING MANUFACTURING D/BASE Andy in Worcester Microsoft Access Getting Started 1 25th Jun 2009 05:42 AM
Word Mail Merge w/Access Data Base - reports empty data base recor =?Utf-8?B?U3RldmUgUnV0bGVkZ2U=?= Microsoft Access Macros 1 13th Apr 2007 08:48 PM
How do I convert a msworks data base file to an Excel data base? =?Utf-8?B?SHVudGluZ3Rvbg==?= Microsoft Access External Data 1 5th Sep 2006 06:36 AM
moving a table from one copy of the data base back to data base =?Utf-8?B?Um9iaW4gRi4=?= Microsoft Access 1 2nd Apr 2005 02:21 AM
Building a knowledge base =?Utf-8?B?ZnJlZGR5?= Microsoft Access Database Table Design 1 23rd Aug 2004 03:53 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:46 AM.