marcellvries
Programmer
Hi there,
I'm developing a database (planning system) and I'm facing the following problem.
When I click on a button on the form, I would like to add all records from tblPlanning with Confirm = true to tblRealisatie and subsequently remove those records from tblPlanning. So in fact I would like to move records from tblPlanning to tblRealisatie.
I just can't get the insert and delete parts to work at the same time. What do I do wrong? The code is below.
With kind regards,
Marcell
-------
Private Sub cmdRealiseren_Click()
Dim rsRealiseren As ADODB.Recordset
Dim rsDelete As ADODB.Recordset
Dim sqlRealiseren As String
Dim sqlDelete As String
Set rsRealiseren = New ADODB.Recordset
Set rsDelete = New ADODB.Recordset
sqlRealiseren = "INSERT INTO tblRealisatie " _
& "SELECT * FROM tblPlanning " _
& "WHERE Confirm = True;"
sqlDelete = "DELETE * FROM tblPlanning WHERE Confirm = True;"
rsRealiseren.ActiveConnection = CurrentProject.Connection
rsRealiseren.Source = sqlRealiseren
rsRealiseren.CursorType = adOpenDynamic
rsRealiseren.LockType = adLockOptimistic
rsRealiseren.Open
Set rsRealiseren = Nothing
rsDelete.ActiveConnection = CurrentProject.Connection
rsDelete.Source = sqlDelete
rsDelete.CursorType = adOpenDynamic
rsDelete.LockType = adLockOptimistic
rsDelete.Open
Set rsDelete = Nothing
Forms!frmPlanningRealiseren.Requery
End Sub
I'm developing a database (planning system) and I'm facing the following problem.
When I click on a button on the form, I would like to add all records from tblPlanning with Confirm = true to tblRealisatie and subsequently remove those records from tblPlanning. So in fact I would like to move records from tblPlanning to tblRealisatie.
I just can't get the insert and delete parts to work at the same time. What do I do wrong? The code is below.
With kind regards,
Marcell
-------
Private Sub cmdRealiseren_Click()
Dim rsRealiseren As ADODB.Recordset
Dim rsDelete As ADODB.Recordset
Dim sqlRealiseren As String
Dim sqlDelete As String
Set rsRealiseren = New ADODB.Recordset
Set rsDelete = New ADODB.Recordset
sqlRealiseren = "INSERT INTO tblRealisatie " _
& "SELECT * FROM tblPlanning " _
& "WHERE Confirm = True;"
sqlDelete = "DELETE * FROM tblPlanning WHERE Confirm = True;"
rsRealiseren.ActiveConnection = CurrentProject.Connection
rsRealiseren.Source = sqlRealiseren
rsRealiseren.CursorType = adOpenDynamic
rsRealiseren.LockType = adLockOptimistic
rsRealiseren.Open
Set rsRealiseren = Nothing
rsDelete.ActiveConnection = CurrentProject.Connection
rsDelete.Source = sqlDelete
rsDelete.CursorType = adOpenDynamic
rsDelete.LockType = adLockOptimistic
rsDelete.Open
Set rsDelete = Nothing
Forms!frmPlanningRealiseren.Requery
End Sub