Hi All,
I'm having some problems trying to move a row from on table to another using a button.
Basically I have two tables. One has names on it(called Customers) the other is blank(called DeletedCustomers).
I have a Form which has a drop down combo box and three text boxes. If you click on the combo box and select a customer; the firstnames, lastnames and ID number will be shown in the three text boxes. There is also a button which will add names to the customer table if you have typed names in the text boxes.
What I would like is to have another button which when pressed, depending on which customer name is selected in the text boxes, will move the name from the Customer table to the DeletedCustomer table.
This is the code I have, which is more than likely wrong..
Private Sub Command38_Click()
On Error GoTo Err_Command38_Click
If MsgBox("Are you sure you want to delete this record?", vbExclamation + vbYesNo, "") = vbYes Then
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSelectRecord
INSERT Into DeletedCustomers(Column1, Column2)
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
Else 'user clicked no
MsgBox "Deletion was aborted.", vbInformation
End If
Exit_Command38_Click:
Exit Sub
Err_Command38_Click:
MsgBox Err.Description
Resume Exit_Command36_Click
End Sub
Any help on this would be greatly appreciated
Cheers
Dom
I'm having some problems trying to move a row from on table to another using a button.
Basically I have two tables. One has names on it(called Customers) the other is blank(called DeletedCustomers).
I have a Form which has a drop down combo box and three text boxes. If you click on the combo box and select a customer; the firstnames, lastnames and ID number will be shown in the three text boxes. There is also a button which will add names to the customer table if you have typed names in the text boxes.
What I would like is to have another button which when pressed, depending on which customer name is selected in the text boxes, will move the name from the Customer table to the DeletedCustomer table.
This is the code I have, which is more than likely wrong..
Private Sub Command38_Click()
On Error GoTo Err_Command38_Click
If MsgBox("Are you sure you want to delete this record?", vbExclamation + vbYesNo, "") = vbYes Then
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSelectRecord
INSERT Into DeletedCustomers(Column1, Column2)
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
Else 'user clicked no
MsgBox "Deletion was aborted.", vbInformation
End If
Exit_Command38_Click:
Exit Sub
Err_Command38_Click:
MsgBox Err.Description
Resume Exit_Command36_Click
End Sub
Any help on this would be greatly appreciated
Cheers
Dom