Results 1 to 6 of 6
  1. #1
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    237

    Deletion button on subform for a selected record

    Hi to All,



    A subForm (Default View: Continuous View) on a main Form has records. The subForm has Allow Edits = No and Allow Deletions=No. This is done to prevent editing after the record is saved and to prevent deletion by mistake. Beside each record on the sub Form there are two buttons: Print button to print the selected record (Is functional) and a delete button.

    If the delete button is clicked for a saved record then a message box shows asking to confirm the operation or not. If deletion is confirmed then a check box is turned on for a field named MarkedDeleted (Yes/No) and the subform is re query.

    If the delete button is clicked while editing a new record then cancel the editing of this new record.

    The third case is if record selector is on new record, message box saying you need to select a record before deletion.


    How can this be done?

    Khalil

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    something like:
    update query : "quMark4Delete" is Update table set [mark] = true

    Code:
    sub btnDelete_click()
    Code:
    if ask("Delete ID:" & txtID ) then
       Hrglass
         docmd.openquery "quMark4Delete"
       Hrglass false
    endif
    end sub
    
    
    
    Public Function Ask(ByVal pvMsg) As Boolean
    Ask = MsgBox(pvMsg & "?", vbQuestion + vbYesNo, "Confirm") = vbYes
    End Function
    
    
    
    Public Sub HrGlass(Optional ByVal pbOn As Boolean = True)
    DoCmd.Hourglass pbOn
    DoCmd.SetWarnings Not pbOn
    DoEvents
    End Sub

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You can check if you're on a new record with

    If Me.NewRecord = True Then
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    237
    Hi,
    Thank you guys for the ideas. I am still working on it. I will keep you posted.

    Question:
    What VBA code for Sub Form to enable the AllowEdits property?
    Thanks

  5. #5
    orange's Avatar
    orange is online now Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722

  6. #6
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    237
    Hi,
    Thank you all for the help.
    I reviewed: https://docs.microsoft.com/en-us/off...orm.allowedits

    Khalil

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

Similar Threads

  1. print selected record on a subform
    By Khalil Handal in forum Access
    Replies: 4
    Last Post: 04-11-2022, 01:31 AM
  2. Replies: 3
    Last Post: 08-16-2018, 09:52 AM
  3. Replies: 4
    Last Post: 05-11-2018, 12:18 PM
  4. Button open selected record in subform table, in new form
    By BrainExplodingFromCoffee in forum Forms
    Replies: 4
    Last Post: 04-12-2016, 02:19 PM
  5. Replies: 2
    Last Post: 03-03-2015, 07:20 AM

Tags for this Thread

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