Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Really appreciate your site. Really good site for learning what others do when they run into problems. You guy's are great!!!..."

Geography

Where in the world do Tek-Tips members come from?
exRP12Nuke (TechnicalUser)
6 Jul 12 13:35
Hello,

I have an append query that runs each time my VBA code is ran. This append query takes values from one table and stores it in another table for a historical record. However, if the values that it pulls have not changed from the last time the program ran, it creates a duplicate entry within the history table.

I found a small bit of code in the FAQ discussion area here, and it is a good start, but it does not return the values that I need it to.

CODE

DELETE [LastCOHrs] FROM [tblCOHist] WHERE [ID] Not In (SELECT Max([ID]) FROM [tblCOHist] GROUP BY [LastCOHrs]); 

It does delete ALL duplicate records from the LastCOHrs column in the table. The fields that are in the tblCOHist table are SN, CompCOde, ModCode, and LastCOHrs. It is possible to have multiple entries for SN, CompCode, and ModCode, but I do not want multiple entries for the LastCOHrs field.

I have attached a sample spreadsheet of what the history table looks like, any help would be greatly appreciated.

CODE

SN	CompCode2	 ModCode	LastCOHrs	
A	        1		       10	
A	        2		        5	
A	        3		        7	
A	        4	 	        8	
A	        5	      L	       45	
A	        5	      R	       52	
A	        1	 	       10 	Duplicate entry - this one needs to be deleted
A	        1 	               500	This one is ok 
Thanks!

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close