Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add query

Status
Not open for further replies.

Superguppie

Technical User
Jan 19, 2005
107
NL
Hey there,

I have an Add Query that adds all records from the query to a table. now each time i run the query it adds the records again. what the query must do is, only add new records to the table AND old records but only when the field
Code:
 has changed.

Is this possible?
im open for suggestions


Greetz Superguppie
 
thats the problem i dont know what to fill in by SQL

im new to SQL so.

What i want is:

Table1:
Productname
Location

A form that can change the location.
when the location is changed, Before update, the record in table1 must be copied to another table. so you can see a history where the device has been. so if the record is going to change, the old record must be copied to the table, also when the second change comes, he must copy it to the table but no to delete the first record in the table....

is this possible?

Greetz
 
You say:

I have an Add Query that adds all records from the query to a table

It will have SQL. Choose SQL view from the query design window.
 
srry about that. i found it

here it is:

INSERT INTO tblTEST ( Borentcode, Filliaalnummer )
SELECT tblApparaten.Borentcode, tblApparaten.Filliaalnummer
FROM tblApparaten;
 
I suggest you run some SQL in the After Update event of your form, for example:

Code:
'Assumes numeric tblApparaten.Borentcode
strSQL="INSERT INTO tblTEST ( Borentcode, " _
& "Filliaalnummer ) " _
& "SELECT tblApparaten.Borentcode, " _
& "tblApparaten.Filliaalnummer " _
& "FROM tblApparaten " _
& "WHERE tblApparaten.Borentcode = " & Me.Borentcode

CurrentDB.Execute strSQL, dbFailOnError

You will need to check to see if the update should be saved.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top