Prevent Append of Multiple/Duplicate records

Posted on 2004-11-15
Last Modified: 2012-06-27

I have a table called 'Year' in which I have a field called the 'WeekNo'.I append the records into this table every week & flood the weekno field with a number for that particular weekno(which are in sequence week after week).Actually,the append is to be done automatically with the help of a macro which would run the append Query everytime I open the Database.

ex.if I open the database this week,I would flood the 'WeekNo' field with week when I open the database & append the new records,I would flood the 'WeekNo' field with No=2 for those new on & so forth..

For instance,the append operation for the records is done every Monday.

My question is if I open the database more than once anyday in middle of a week,...I need a check that would tell me that the records for that particular week have already been appended..

How would a go about doing it..Do i write a query or a trigger function.?
Question by:bluetornado_666
    LVL 8

    Accepted Solution

    Use a left join:

    insert into Year (Column1, Column2 etc)
    Select w.Column1, w.Column2 etc)
    from tblWeek w left join
    Year y
    on w.IDColumn = y.WeeksIDColumn
    Where y.WeeksIDColumn is null

    In the GUI, do the link by drag and drop then get the properties on the line linking the table, ensure you select all from the week table and matching from Year

    In the criteria column put the Year DI column and specify Is Null.
    LVL 8

    Expert Comment

    Oh play with it as a select statement and when you are happy change it to an append / insert query.

    Author Comment

    Hi Simon,

    The 'Is Null' clause did work for a few queries on cetain tables, but the computer system almost hangs up (for many tables which have large no of records),while validating this criteria.

    Also if my query has a lot many criterias in it,then also the 'Is NULL' clause does not work.

    Is there any other way of doing it..anything effecient & faster as well...instead of using "Is NULL"

    LVL 8

    Expert Comment

    Nope if you have criteria is null is going to as fast as any other way I can think of in a dynamic way. try putting indices on these columns:


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    The first two articles in this short series — Using a Criteria Form to Filter Records ( and Building a Custom Filter ( — discuss in some detail how a form can be…
    Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
    In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now