Home > Software engineering >  About the use of SQL statements in the access database replication in the same form to copy the whol
About the use of SQL statements in the access database replication in the same form to copy the whol

Time:10-04

I realize: is the purpose of requirements using SQL statements in the same copy a whole row of data in a table at the end of the line,
The form has the following two features
Line 1, have a primary key, the primary key automatically increase,
2, column headings many
The problems is to use SQL statements SQL="insert into" & amp; Me. The Name & amp; "The select * from" & amp; Me. The Name & amp; "Where the style name='" & amp; Rs. Fields (name of "style") & amp; "'
"Always prompt "because of will in the index, primary key, or relationship to create duplicate values, a request for the change table without success, to change the field of data in the field of or containing duplicate data, delete index or redefine index to allow duplicate values and try again," and I think the main reason is to copy the whole record in at the last insert primary key id also copy the same id, id at this time there is no automatic increase, so the primary key repeat, copy the insert fails, ask ace to give directions, feeling

CodePudding user response:

Insert into table (field list) from the select field list table where conditions

CodePudding user response:

Back upstairs, I a lot of fields, field list probably dozens, although your method feasible, but the readability of the program is not good,

CodePudding user response:

Use field list is one of the most simple method, there are dozens of field? Table design does not pay attention to.

In fact, you can talk about the field in the table gives a string variable or constant, reference in the SQL statement,

If must need not field list, you can use a temporary table:

"The Delete From Temp
""Insert into Temp select * from" & amp; Me. The Name & amp; "Where the style name='" & amp; Rs. Fields (name of "style") & amp; "'
""The Update Temp Set ID=" "
"Insert into" & amp; Me. The Name & amp; "Select * from Temp
"
  • Related