从第一个表删除数据后如何将数据从一个表追加到另一个表

时间:2018-07-04 16:08:52

标签: ms-access

我有一个名为frmSales的销售输入表格。在此frmSales上,我还拥有一个名为tblSalesMAIN subform2的连续表格,该表格具有与frmSales相同的数据源。我试图在frmSales和tblSalesMAIN subform2的数据源(即tblSalesMAIN)中创建条目,并将所有当前数据附加到称为tblSalesMAIN1的单独表中。之后,将删除tblSalesMAIN的所有内容,以便为重新输入腾出空间。 以下是我尝试不成功的方法。评论的代码是我不知道的。 感谢您的协助

Private Sub cmdClear_Click()
 'Dim dbs As DAO.Database
 'set dbs = Current.OpenRecordset("SELECT * FROM [tblSalesMAIN]")
 'dbs.Execute " INSERT INTO tblSalesMAIN1 " _
 '& "SELECT * "
 '& "FROM [tblSalesMAIN];"
 'dbs.Close


 'INSERT INTO tblSalesMAIN1 [(salesID[, salesTime[, salesDate[, unitPrice[, quantity[, cashTendered[, change[, price]]]]]]])] SELECT ([tblSalesMAIN.SalesID[, tblSalesMAIN.salesTime[, tblSalesMAIN.salesDate[, tblSalesMAIN.unitPrice[, tblSalesMAIN.quantity[, tblSalesMAIN.cashTendered[, tblSalesMAIN.change[, tblSalesMAIN.price]]]]]]])

 'DoCmd.RunQuery 


 If MsgBox("You are about to delete all records. Are you sure?", _
 vbQuestion + vbYesNo) = vbNO Then
 Exit Sub
 End If
 strSQL = "DELETE*FROM tblSalesMAIN subform2"
 DoCmd.SetWarnings False
 DoCmd.RunSQL
 DoCmd.SetWarnings True
 Me.Requery
 Me.Refresh

 End Sub


 Private Sub cmdd_Click()
 DoCmd.GoToRecord , "", acNewRec
 Me.Refresh

 End Sub
enter code here

0 个答案:

没有答案