I have two questions regarding my code:
1. Private Sub cmd_DeleteCustomer_Click()
Dim Answer As String
If IsNull(Me.CustomerID) Then
MsgBox ("Please select a building")
Exit Sub
End If
Answer = MsgBox("Delete Building?", vbQuestion + vbYesNo, "Confirm")
Select Case Answer
Case vbYes
CurrentDb.Execute "Delete * From Customer Where CustomerID = " &
Me.CustomerID
DoCmd.Requery
Case vbNo
Exit Sub
End Select
End Sub
The code above deletes the record from the Table Building, which is subform on Form Customer, displayed as datasheet. I want to know, how to make this code to delete not just one record selected, but any records I have currently (many) selected ?
The second question:
Code below closes the form and pops us the message whenever form has been changed, however it only does when i make change to Customer Form, but does not work for Building_Subform on this form. I tried Me.Building_Subform.Form.Dirty Then.... but it does not seem to work.
2. Private Sub cmd_CloseCustomerInfo_Click()
Dim Answer As String
If Me.Dirty Then
Answer = MsgBox("Do you want save changes?", vbQuestion + vbYesNoCancel, "Confirm")
Select Case Answer
Case vbYes
DoCmd.RunCommand acCmdSaveRecord
DoCmd.RunCommand acCmdClose
Case vbNo
DoCmd.RunCommand acCmdUndo
DoCmd.RunCommand acCmdClose
Case vbCancel
Exit Sub
End Select
Else
DoCmd.RunCommand acCmdClose
End If
End Sub
Any suggestions will be most welcomed
Thank you