Results 1 to 4 of 4
  1. #1
    Evgeny's Avatar
    Evgeny is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2010
    Posts
    85

    Delete and Dirty functions

    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

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    ca you give me more details regarding the relationships of the tables involved here (Forms). i can then try to help you with the little knowledge that i have. I need tables and the relationships.

  3. #3
    Evgeny's Avatar
    Evgeny is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2010
    Posts
    85
    i have attached pics depicting relationship and current tables and forms. Customer form is the primarily form. Building_Subform is located within displayed as datasheet. Regards

  4. #4
    Evgeny's Avatar
    Evgeny is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2010
    Posts
    85
    Any ideas ?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Functions
    By jamin14 in forum Programming
    Replies: 1
    Last Post: 03-25-2010, 08:16 AM
  2. Help with functions / procedures
    By curnil in forum Programming
    Replies: 3
    Last Post: 03-09-2010, 05:41 PM
  3. Sorting and creating functions
    By BUS 101 in forum Access
    Replies: 1
    Last Post: 09-15-2009, 02:13 PM
  4. Concatenation, nested IIF functions
    By krymer in forum Queries
    Replies: 2
    Last Post: 10-20-2008, 07:27 AM
  5. Multiple IIF functions possible?
    By Northgate in forum Access
    Replies: 0
    Last Post: 10-08-2008, 01:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums