append only if [status] is different

G

Guest

I have the following APPEND QUERY:

INSERT INTO tbl_archive ( [Loan Acct #], status, PopEnterDt )
SELECT tbl_history.[Loan Acct #], tbl_history.status, tbl_history.PopEnterDt
FROM tbl_history;

however, i only want a record from the tbl_history to appended to the
tbl_archive ONLY if the status for the particular [account number] is
different. how can i do this?

thanks in advance,
geebee


thanks
 
O

OfficeDev18 via AccessMonster.com

What's stopping you from using the "WHERE tbl_history.status......" clause?

Sam
I have the following APPEND QUERY:

INSERT INTO tbl_archive ( [Loan Acct #], status, PopEnterDt )
SELECT tbl_history.[Loan Acct #], tbl_history.status, tbl_history.PopEnterDt
FROM tbl_history;

however, i only want a record from the tbl_history to appended to the
tbl_archive ONLY if the status for the particular [account number] is
different. how can i do this?

thanks in advance,
geebee

thanks
 
G

Guest

I am already using this:

INSERT INTO tbl_archive ( [Loan Acct #], status, PopEnterDt )
SELECT tbl_history.[Loan Acct #], tbl_history.status, tbl_history.PopEnterDt
FROM tbl_history LEFT JOIN Tbl_archive ON Tbl_history.[Loan Acct
#]=Tbl_archive.[Loan Acct #]
WHERE (((Tbl_archive.status)<>tbl_history.status));

However, all records are being appended from tbl_history into tbl_archive
EVEN if the record already exists in tbl_archive. For example, if loan
account number 456 with a status of 5 exists in tbl_history, and that exact
same record exists in tbl_archive, that record is still being appended to the
tbl_archive. This should NOT be happening. What am I doing wrong?

thanks in advance,
geebee

OfficeDev18 via AccessMonster.com said:
What's stopping you from using the "WHERE tbl_history.status......" clause?

Sam
I have the following APPEND QUERY:

INSERT INTO tbl_archive ( [Loan Acct #], status, PopEnterDt )
SELECT tbl_history.[Loan Acct #], tbl_history.status, tbl_history.PopEnterDt
FROM tbl_history;

however, i only want a record from the tbl_history to appended to the
tbl_archive ONLY if the status for the particular [account number] is
different. how can i do this?

thanks in advance,
geebee

thanks
 
O

OfficeDev18 via AccessMonster.com

Oh, OK. Try changing your join as follows:

LEFT JOIN Tbl_archive ON (Tbl_history.[Loan Acct #]=Tbl_archive.[Loan Acct #])
And (Tbl_history.status = Tbl_archive.status). Then change the WHERE clause
to:

WHERE Tbl_archive.status Is Null;

See if this helps.

Sam
I am already using this:

INSERT INTO tbl_archive ( [Loan Acct #], status, PopEnterDt )
SELECT tbl_history.[Loan Acct #], tbl_history.status, tbl_history.PopEnterDt
FROM tbl_history LEFT JOIN Tbl_archive ON Tbl_history.[Loan Acct
#]=Tbl_archive.[Loan Acct #]
WHERE (((Tbl_archive.status)<>tbl_history.status));

However, all records are being appended from tbl_history into tbl_archive
EVEN if the record already exists in tbl_archive. For example, if loan
account number 456 with a status of 5 exists in tbl_history, and that exact
same record exists in tbl_archive, that record is still being appended to the
tbl_archive. This should NOT be happening. What am I doing wrong?

thanks in advance,
geebee
What's stopping you from using the "WHERE tbl_history.status......" clause?
[quoted text clipped - 14 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

query error 1
DUPLICATE QUERY results 1
yikes 7
append query 3
query not acting right 5
query problems 5
conditional criteria 4
change to UPDATE query 3

Top