Results 1 to 5 of 5
  1. #1
    besuchanko is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2013
    Posts
    32

    Checkbox on Subform not Writing to Table

    I'm halfway there on this but need some help. I have a main form with a subform. When I update the textbox on the main form (Submission_Title), I use the AfterUpdate event to check a checkbox on the subform. That works fine. But when the checkboxes get checked on the subform, they don't write back to the table linked to the subform (tblPinkSheetData). How do I get it to write to the table??

    Code:
    Private Sub Submission_Title_AfterUpdate()
    
    Me.tblPinkSheetData_subform.Form!R1.Value = -1
    
    
    End Sub


  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,799
    You are probably not saving the record you've just modified. Could try adding something like
    Forms!NameOYourfMainform.tblPinkSheetData_subform. Form.dirty = false

    or do something to move off of the subform record. Remotely possible that the table is already open and you're switching back to it but not refreshing the view.
    EDIT - code edited.
    Last edited by Micron; 03-11-2021 at 08:37 PM. Reason: spelin and gramur
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    apr pillai's Avatar
    apr pillai is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    May 2010
    Location
    Alappuzha, India
    Posts
    209
    Quote Originally Posted by besuchanko View Post
    I'm halfway there on this but need some help. I have a main form with a subform. When I update the textbox on the main form (Submission_Title), I use the AfterUpdate event to check a checkbox on the subform. That works fine. But when the checkboxes get checked on the subform, they don't write back to the table linked to the subform (tblPinkSheetData). How do I get it to write to the table??

    Code:
    Private Sub Submission_Title_AfterUpdate()
    
    Me.tblPinkSheetData_subform.Form!R1.Value = -1
    
    
    End Sub
    Add one more line to your subroutine.
    Code:
    Private Sub Submission_Title_AfterUpdate()
    
    Me.tblPinkSheetData_subform.Form!R1.Value = -1
    
    DoCmd.Save Me.CurrentRecord
    End Sub

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,799
    Private Sub Submission_Title_AfterUpdate()
    That code is on the main form so DoCmd.Save Me.CurrentRecord applies to the main form. However the edited checkbox is on a subform?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    apr pillai's Avatar
    apr pillai is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    May 2010
    Location
    Alappuzha, India
    Posts
    209
    You are correct Micron, sometimes I am so careless and hurry with responses.
    Code:
    Private Sub Submission_Title_AfterUpdate()
    Dim frm as Form
        set frm = Me.tblPinkSheetData_subform.Form
        frm!R1 = -1
        DoCmd.Save frm.CurrentRecord
    End Sub
    I hope it will work, but not tested.

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

Similar Threads

  1. Need to filter a subform using a checkbox
    By Thomasso in forum Forms
    Replies: 5
    Last Post: 12-08-2020, 09:35 AM
  2. Checkbox on subform
    By SunTop in forum Access
    Replies: 2
    Last Post: 07-16-2018, 11:27 AM
  3. Replies: 49
    Last Post: 01-29-2018, 05:52 PM
  4. Binding a checkbox to a subform
    By Bhat59 in forum Forms
    Replies: 3
    Last Post: 10-20-2011, 08:48 PM
  5. Replies: 2
    Last Post: 06-20-2010, 06:54 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