Hello all,
I have a table where I register the configuration of different elements for various events. The fields of this table are: "ElementName", "Configuration" and "Event". Field "Event" is a lookup to a table where I also have a date field. I have a form where I show the user the Event and its date among other fields. The configurations for each event change very slightly from one to another, so I wanted to allow the user to load the immediate previous event's configurations by clicking on a button, allowing a faster update. It is important for me to keep a register of all the configurations used for all the events.
I created a parameter query that extracts from the table a set of records using the date of the event opened in a form to get the previous event: the idea is that the query gets the configuration of the previous event to the one I am working on (the one opened in the form).
Now, I would like to "copy" the records from the query and paste them to the same table, but updating the Event field to the one opened in the form.
I have found this code on the Internet that I believe would be useful but I am not sure how to adapt it to VBA so that I can run it when clicking on a button of the form:
Thanks a lot
I have a table where I register the configuration of different elements for various events. The fields of this table are: "ElementName", "Configuration" and "Event". Field "Event" is a lookup to a table where I also have a date field. I have a form where I show the user the Event and its date among other fields. The configurations for each event change very slightly from one to another, so I wanted to allow the user to load the immediate previous event's configurations by clicking on a button, allowing a faster update. It is important for me to keep a register of all the configurations used for all the events.
I created a parameter query that extracts from the table a set of records using the date of the event opened in a form to get the previous event: the idea is that the query gets the configuration of the previous event to the one I am working on (the one opened in the form).
Now, I would like to "copy" the records from the query and paste them to the same table, but updating the Event field to the one opened in the form.
I have found this code on the Internet that I believe would be useful but I am not sure how to adapt it to VBA so that I can run it when clicking on a button of the form:
SQL:
CREATE table temp_table AS SELECT * FROM conf_query;
UPDATE temp_table SET Event="NewEvent";
UPDATE temp_table SET ID=NULL
INSERT INTO conf_table SELECT * FROM temp_table;
DROP TABLE temp_table
Thanks a lot