Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / November 2005

Tip: Looking for answers? Try searching our database.

Append Query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Build or Die - 15 Nov 2005 18:07 GMT
I have a many to many relationship that I'm trying to use an append query on:

tblContacts - ContactID (primary key), name, etc...
tblMailingList - ListID (primary key), list name
tblMailingListLINK - ContactID & TableID (one to many relationship from
above tables) and a yes/no field called 'Included'

On my form I'd like to use an append query when a list is selected from a
combo box to add any contacts that may have been added since the last time
the list was worked on.

I've created the append query, but its not ignoring duplicates.  Other posts
say that it should do this automatically... where did I go wrong?

here's the query code:

INSERT INTO tblMailingListLink ( ContactID, ListID )
SELECT tblContacts.ContactID, forms!frmmailinglist.listselect AS ListID
FROM tblContacts
WHERE (((tblContacts.RemoveFromList)=No));

Thanks for reading!
Ofer - 16 Nov 2005 00:06 GMT
What is the primary key in tblMailingListLink , if you didnt define any, this
is why its appending duplicates

Signature

I hope that helped
Good Luck

> I have a many to many relationship that I'm trying to use an append query on:
>
[quoted text clipped - 18 lines]
>
> Thanks for reading!
Build or Die - 16 Nov 2005 13:20 GMT
I just added a primary key 'ListingID' (autonumber) to the table
tblMailingListLink.  I sampled the append query and it still wanted to add
another 700 records.  I also tried to add the new primary key to the query
and that didn't help either.  Is it the autonumber thats messing this up?  Or
do my relationships need to be modified from the default?  

Thanks.

> What is the primary key in tblMailingListLink , if you didnt define any, this
> is why its appending duplicates
[quoted text clipped - 21 lines]
> >
> > Thanks for reading!
Ofer - 16 Nov 2005 14:00 GMT
The new field, the auto number, can't be use to remove the duplicates.
You have to decide which fields you don't want to repeat, and declare the
combination of fields as your key

Signature

I hope that helped
Good Luck

> I just added a primary key 'ListingID' (autonumber) to the table
> tblMailingListLink.  I sampled the append query and it still wanted to add
[quoted text clipped - 29 lines]
> > >
> > > Thanks for reading!
Build or Die - 16 Nov 2005 15:26 GMT
Thanks for helping me out on this.... Something must be wrong with me
today... I can't get this to work correctly.

I've removed the 'autonumber' field and set a primary key on the two fields
that will append in the tblMailingListLink - ContactID and ListID.  ListID is
a constant? Could that be an issue?  The relationships and query have not
changed. What else could be left?    

> The new field, the auto number, can't be use to remove the duplicates.
> You have to decide which fields you don't want to repeat, and declare the
[quoted text clipped - 33 lines]
> > > >
> > > > Thanks for reading!
Ofer - 16 Nov 2005 15:50 GMT
In the append query, change the syntax to

Insert Into TableName (Field1, Field2)
Select Distinct Field1, Field2 From TableName

In the select part add distinct

Or, open the query in design view, open the properties, and change the
Unique values property to Yes, it will add the distict for you

Signature

I hope that helped
Good Luck

> Thanks for helping me out on this.... Something must be wrong with me
> today... I can't get this to work correctly.
[quoted text clipped - 41 lines]
> > > > >
> > > > > Thanks for reading!
Build or Die - 16 Nov 2005 21:29 GMT
Just when I thought that was going to do it - not there yet.
My new syntax:

INSERT INTO tblMailingListLink ( ContactID, ListID )
SELECT DISTINCT tblContacts.ContactID, forms!frmmailinglist.listselect AS
ListID
FROM tblContacts
WHERE (((tblContacts.RemoveFromList)=No));

It seems like this should resolve any query problems.  Would having 'enforce
referential integrity' set on in the relationships be a problem?

Got anymore tips for the guy who can't get an append query to work on a many
to many relationship?

Thanks for all your help.

> In the append query, change the syntax to
>
[quoted text clipped - 51 lines]
> > > > > >
> > > > > > Thanks for reading!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.