Duplcate Records

H

Harddrive747

Guys, I have created a database of activities. In this database there is a
table called Activity that has and ID field. I have also created a table of
Contacts with a contact ID.

All the activities will have a contact person, even if they are unknown.
However, some of these activities can have multiple contacts (No more than
two.) So I created a third table that has the ID from the Activities table
and the ID from the contact table.

So I'm able to create a query based on this third table, and get all the
records that match. I can pull that data into FrontPage and print it out.
The problem is that I get two copies of the same activity, each with a
different contact.

What I would like to do is to be able to print one copy of the activity, but
have both contacts printed on the line. So basically I want to not print the
duplicate activity record if there are two contacts.

So any help would be greatly apprechiated.
 
S

Stefan B Rusynko

Does the third table have the activity as a unique record and the contacts as fields for each activity record




| Guys, I have created a database of activities. In this database there is a
| table called Activity that has and ID field. I have also created a table of
| Contacts with a contact ID.
|
| All the activities will have a contact person, even if they are unknown.
| However, some of these activities can have multiple contacts (No more than
| two.) So I created a third table that has the ID from the Activities table
| and the ID from the contact table.
|
| So I'm able to create a query based on this third table, and get all the
| records that match. I can pull that data into FrontPage and print it out.
| The problem is that I get two copies of the same activity, each with a
| different contact.
|
| What I would like to do is to be able to print one copy of the activity, but
| have both contacts printed on the line. So basically I want to not print the
| duplicate activity record if there are two contacts.
|
| So any help would be greatly apprechiated.
 
H

Harddrive747

Stefan, the third table that I descirebed does not have a unique record
because this is an intermidate table between the Activities table and the
Contact table.

So each activity may have one or two contacts. I tried to put the two
contacts into the same table, but when I query the contact table, I get zero
records. So I figure use a third table that has only two fields in it. One
is the Activity_ID and the other is a Contact_ID field. So if an activity
has two contacts it will have the number of the activity plus the contact id.
I would create two records for the activity in the middle table.

If I write this report in Access, it works great because it understands what
I want, but in the web it doesn't. So I'm trying to figure out how to get
the one activity printed with two contacts.

I hope this clarifies things.
Terry
 
T

TJ

Found it!

Confused-- a Little.
What is the "Link" from Activity_ID that lets you know what the right
Contact_ID field or Field(s) are?

Thinking you might use nested queries... Like MySQL..
SELECT DISTINCT t1.* FROM t1,t2 WHERE t1.id=t2.id;
or the long way of
SELECT * FROM t1 WHERE id IN (SELECT id FROM t2);

I'll look at this closer tomorrow

TJ

| Stefan, the third table that I descirebed does not have a unique record
| because this is an intermidate table between the Activities table and the
| Contact table.
|
| So each activity may have one or two contacts. I tried to put the two
| contacts into the same table, but when I query the contact table, I get
zero
| records. So I figure use a third table that has only two fields in it.
One
| is the Activity_ID and the other is a Contact_ID field. So if an activity
| has two contacts it will have the number of the activity plus the contact
id.
| I would create two records for the activity in the middle table.
|
| If I write this report in Access, it works great because it understands
what
| I want, but in the web it doesn't. So I'm trying to figure out how to get
| the one activity printed with two contacts.
|
| I hope this clarifies things.
| Terry
|
| "Stefan B Rusynko" wrote:
|
| > Does the third table have the activity as a unique record and the
contacts as fields for each activity record
| >
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > To find the best Newsgroup for FrontPage support see:
| > http://www.net-sites.com/sitebuilder/newsgroups.asp
| > _____________________________________________
| >
| >
| > | Guys, I have created a database of activities. In this database there
is a
| > | table called Activity that has and ID field. I have also created a
table of
| > | Contacts with a contact ID.
| > |
| > | All the activities will have a contact person, even if they are
unknown.
| > | However, some of these activities can have multiple contacts (No more
than
| > | two.) So I created a third table that has the ID from the Activities
table
| > | and the ID from the contact table.
| > |
| > | So I'm able to create a query based on this third table, and get all
the
| > | records that match. I can pull that data into FrontPage and print it
out.
| > | The problem is that I get two copies of the same activity, each with a
| > | different contact.
| > |
| > | What I would like to do is to be able to print one copy of the
activity, but
| > | have both contacts printed on the line. So basically I want to not
print the
| > | duplicate activity record if there are two contacts.
| > |
| > | So any help would be greatly apprechiated.
| >
| >
| >
 
H

Harddrive747

TJ, here is the basic design of the database. I will shorten them as The
tables have too many field in them.

Activities Activity_Contact Contacts
Activity_ID Activity_ID Contact_ID Contact_ID

So in the Activity_Contact table, I can have multiple Activity_ID and
multiple Contact_ID.

So I want the Activity from the Activities table to print only one record,
but if they have two contacts the second contact is printed. I can't put two
fields into the Activities, because then I can't even pull the record.

So the output would look something like

Social on Sat, 26 Nov
7 p.m.
Location
Description
Contact #1
Contact #2 (if there is one)

If you do this in Access and create a report it works perfectly, but I'm
trying to get it done in a web page.

I hope this clarifies it. I will need to take a closer look at this over
the weekend.

Thanks for the help

TJ said:
Found it!

Confused-- a Little.
What is the "Link" from Activity_ID that lets you know what the right
Contact_ID field or Field(s) are?

Thinking you might use nested queries... Like MySQL..
SELECT DISTINCT t1.* FROM t1,t2 WHERE t1.id=t2.id;
or the long way of
SELECT * FROM t1 WHERE id IN (SELECT id FROM t2);

I'll look at this closer tomorrow

TJ

| Stefan, the third table that I descirebed does not have a unique record
| because this is an intermidate table between the Activities table and the
| Contact table.
|
| So each activity may have one or two contacts. I tried to put the two
| contacts into the same table, but when I query the contact table, I get
zero
| records. So I figure use a third table that has only two fields in it.
One
| is the Activity_ID and the other is a Contact_ID field. So if an activity
| has two contacts it will have the number of the activity plus the contact
id.
| I would create two records for the activity in the middle table.
|
| If I write this report in Access, it works great because it understands
what
| I want, but in the web it doesn't. So I'm trying to figure out how to get
| the one activity printed with two contacts.
|
| I hope this clarifies things.
| Terry
|
| "Stefan B Rusynko" wrote:
|
| > Does the third table have the activity as a unique record and the
contacts as fields for each activity record
| >
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > To find the best Newsgroup for FrontPage support see:
| > http://www.net-sites.com/sitebuilder/newsgroups.asp
| > _____________________________________________
| >
| >
| > | Guys, I have created a database of activities. In this database there
is a
| > | table called Activity that has and ID field. I have also created a
table of
| > | Contacts with a contact ID.
| > |
| > | All the activities will have a contact person, even if they are
unknown.
| > | However, some of these activities can have multiple contacts (No more
than
| > | two.) So I created a third table that has the ID from the Activities
table
| > | and the ID from the contact table.
| > |
| > | So I'm able to create a query based on this third table, and get all
the
| > | records that match. I can pull that data into FrontPage and print it
out.
| > | The problem is that I get two copies of the same activity, each with a
| > | different contact.
| > |
| > | What I would like to do is to be able to print one copy of the
activity, but
| > | have both contacts printed on the line. So basically I want to not
print the
| > | duplicate activity record if there are two contacts.
| > |
| > | So any help would be greatly apprechiated.
| >
| >
| >
 
H

Harddrive747

I will reply to myself on this one.

I got this figured out. What I did was to take the ACTIVITY ID and put it
into a variable, and called it New_Activity_ID. I then comparied it against
the Old_Activity_ID. If those didn't equal, I printed the main information
for the activity. Then at the bottom, I assigned the ACTIVITY ID to the
Old_Activity_ID. Then when it looped to the next record, the New_Activity_ID
got filled with the current record. It again checked to see if the two
values are the same and if they are, then I only had the system print the
next contact and drop out of the routine.

Then I would repeat the process. It works like a champ. In fact, this
helped me solve another issue I was wondering how to do it.

So thanks for all the help and hopefully this may help someone else. Now
it's onto getting the tables updated with new or changed information.

If you know of where I can find information like that, it would be greatly
appreachated.

see ya.
Terry

Harddrive747 said:
TJ, here is the basic design of the database. I will shorten them as The
tables have too many field in them.

Activities Activity_Contact Contacts
Activity_ID Activity_ID Contact_ID Contact_ID

So in the Activity_Contact table, I can have multiple Activity_ID and
multiple Contact_ID.

So I want the Activity from the Activities table to print only one record,
but if they have two contacts the second contact is printed. I can't put two
fields into the Activities, because then I can't even pull the record.

So the output would look something like

Social on Sat, 26 Nov
7 p.m.
Location
Description
Contact #1
Contact #2 (if there is one)

If you do this in Access and create a report it works perfectly, but I'm
trying to get it done in a web page.

I hope this clarifies it. I will need to take a closer look at this over
the weekend.

Thanks for the help

TJ said:
Found it!

Confused-- a Little.
What is the "Link" from Activity_ID that lets you know what the right
Contact_ID field or Field(s) are?

Thinking you might use nested queries... Like MySQL..
SELECT DISTINCT t1.* FROM t1,t2 WHERE t1.id=t2.id;
or the long way of
SELECT * FROM t1 WHERE id IN (SELECT id FROM t2);

I'll look at this closer tomorrow

TJ

| Stefan, the third table that I descirebed does not have a unique record
| because this is an intermidate table between the Activities table and the
| Contact table.
|
| So each activity may have one or two contacts. I tried to put the two
| contacts into the same table, but when I query the contact table, I get
zero
| records. So I figure use a third table that has only two fields in it.
One
| is the Activity_ID and the other is a Contact_ID field. So if an activity
| has two contacts it will have the number of the activity plus the contact
id.
| I would create two records for the activity in the middle table.
|
| If I write this report in Access, it works great because it understands
what
| I want, but in the web it doesn't. So I'm trying to figure out how to get
| the one activity printed with two contacts.
|
| I hope this clarifies things.
| Terry
|
| "Stefan B Rusynko" wrote:
|
| > Does the third table have the activity as a unique record and the
contacts as fields for each activity record
| >
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > To find the best Newsgroup for FrontPage support see:
| > http://www.net-sites.com/sitebuilder/newsgroups.asp
| > _____________________________________________
| >
| >
| > | Guys, I have created a database of activities. In this database there
is a
| > | table called Activity that has and ID field. I have also created a
table of
| > | Contacts with a contact ID.
| > |
| > | All the activities will have a contact person, even if they are
unknown.
| > | However, some of these activities can have multiple contacts (No more
than
| > | two.) So I created a third table that has the ID from the Activities
table
| > | and the ID from the contact table.
| > |
| > | So I'm able to create a query based on this third table, and get all
the
| > | records that match. I can pull that data into FrontPage and print it
out.
| > | The problem is that I get two copies of the same activity, each with a
| > | different contact.
| > |
| > | What I would like to do is to be able to print one copy of the
activity, but
| > | have both contacts printed on the line. So basically I want to not
print the
| > | duplicate activity record if there are two contacts.
| > |
| > | So any help would be greatly apprechiated.
| >
| >
| >
 
S

Stefan B Rusynko

try one of the many ASP tutorial sites like http://www.asp101.com/




| I will reply to myself on this one.
|
| I got this figured out. What I did was to take the ACTIVITY ID and put it
| into a variable, and called it New_Activity_ID. I then comparied it against
| the Old_Activity_ID. If those didn't equal, I printed the main information
| for the activity. Then at the bottom, I assigned the ACTIVITY ID to the
| Old_Activity_ID. Then when it looped to the next record, the New_Activity_ID
| got filled with the current record. It again checked to see if the two
| values are the same and if they are, then I only had the system print the
| next contact and drop out of the routine.
|
| Then I would repeat the process. It works like a champ. In fact, this
| helped me solve another issue I was wondering how to do it.
|
| So thanks for all the help and hopefully this may help someone else. Now
| it's onto getting the tables updated with new or changed information.
|
| If you know of where I can find information like that, it would be greatly
| appreachated.
|
| see ya.
| Terry
|
| "Harddrive747" wrote:
|
| > TJ, here is the basic design of the database. I will shorten them as The
| > tables have too many field in them.
| >
| > Activities Activity_Contact Contacts
| > Activity_ID Activity_ID Contact_ID Contact_ID
| >
| > So in the Activity_Contact table, I can have multiple Activity_ID and
| > multiple Contact_ID.
| >
| > So I want the Activity from the Activities table to print only one record,
| > but if they have two contacts the second contact is printed. I can't put two
| > fields into the Activities, because then I can't even pull the record.
| >
| > So the output would look something like
| >
| > Social on Sat, 26 Nov
| > 7 p.m.
| > Location
| > Description
| > Contact #1
| > Contact #2 (if there is one)
| >
| > If you do this in Access and create a report it works perfectly, but I'm
| > trying to get it done in a web page.
| >
| > I hope this clarifies it. I will need to take a closer look at this over
| > the weekend.
| >
| > Thanks for the help
| >
| > "TJ" wrote:
| >
| > > Found it!
| > >
| > > Confused-- a Little.
| > > What is the "Link" from Activity_ID that lets you know what the right
| > > Contact_ID field or Field(s) are?
| > >
| > > Thinking you might use nested queries... Like MySQL..
| > > SELECT DISTINCT t1.* FROM t1,t2 WHERE t1.id=t2.id;
| > > or the long way of
| > > SELECT * FROM t1 WHERE id IN (SELECT id FROM t2);
| > >
| > > I'll look at this closer tomorrow
| > >
| > > TJ
| > >
| > > | > > | Stefan, the third table that I descirebed does not have a unique record
| > > | because this is an intermidate table between the Activities table and the
| > > | Contact table.
| > > |
| > > | So each activity may have one or two contacts. I tried to put the two
| > > | contacts into the same table, but when I query the contact table, I get
| > > zero
| > > | records. So I figure use a third table that has only two fields in it.
| > > One
| > > | is the Activity_ID and the other is a Contact_ID field. So if an activity
| > > | has two contacts it will have the number of the activity plus the contact
| > > id.
| > > | I would create two records for the activity in the middle table.
| > > |
| > > | If I write this report in Access, it works great because it understands
| > > what
| > > | I want, but in the web it doesn't. So I'm trying to figure out how to get
| > > | the one activity printed with two contacts.
| > > |
| > > | I hope this clarifies things.
| > > | Terry
| > > |
| > > | "Stefan B Rusynko" wrote:
| > > |
| > > | > Does the third table have the activity as a unique record and the
| > > contacts as fields for each activity record
| > > | >
| > > | > --
| > > | >
| > > | > _____________________________________________
| > > | > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > > | > "Warning - Using the F1 Key will not break anything!" (-;
| > > | > To find the best Newsgroup for FrontPage support see:
| > > | > http://www.net-sites.com/sitebuilder/newsgroups.asp
| > > | > _____________________________________________
| > > | >
| > > | >
| > > | > > | > | Guys, I have created a database of activities. In this database there
| > > is a
| > > | > | table called Activity that has and ID field. I have also created a
| > > table of
| > > | > | Contacts with a contact ID.
| > > | > |
| > > | > | All the activities will have a contact person, even if they are
| > > unknown.
| > > | > | However, some of these activities can have multiple contacts (No more
| > > than
| > > | > | two.) So I created a third table that has the ID from the Activities
| > > table
| > > | > | and the ID from the contact table.
| > > | > |
| > > | > | So I'm able to create a query based on this third table, and get all
| > > the
| > > | > | records that match. I can pull that data into FrontPage and print it
| > > out.
| > > | > | The problem is that I get two copies of the same activity, each with a
| > > | > | different contact.
| > > | > |
| > > | > | What I would like to do is to be able to print one copy of the
| > > activity, but
| > > | > | have both contacts printed on the line. So basically I want to not
| > > print the
| > > | > | duplicate activity record if there are two contacts.
| > > | > |
| > > | > | So any help would be greatly apprechiated.
| > > | >
| > > | >
| > > | >
| > >
| > >
| > >
 
Top