Results 1 to 3 of 3

Thread: Changing Values of Text Box on Main Form from Sub Form
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Oct 2008
    Location
    New York, NY
    Posts
    91
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Changing Values of Text Box on Main Form from Sub Form

    I want to change the value of a combo box on a main form based on the update of a combo box on a subform. I have the following:

    Private Sub cmbSubCombo_AfterUpdate()
    If Me.SubCombo.Value = 1 Then


    Me.Parent!cmbMainCombo.Value = 1
    Me.Parent!cmbMainCombo.Locked = True
    If Me.Parent.Dirty Then
    Me.Parent.Dirty = False
    Me.Parent.Refresh


    End If
    End Sub


    I keep getting the 'Write Conflict' Warning. I thought the Me.Dirty sequence would take care of that -- perhaps I'm missing something?
    Last edited by CPGDeveloper; Jun 7th, 2019 at 01:41 PM.

  2. #2
    MrExcel MVP
    Moderator
    xenou's Avatar
    Join Date
    Mar 2007
    Location
    Clev. OH, USA
    Posts
    16,362
    Post Thanks / Like
    Mentioned
    10 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Changing Values of Text Box on Main Form from Sub Form

    I think a lot depends on the details? Is the subform related to the main form (i.e., parent-child or anything of that nature?). How are they related? Also, are the fields bound? If so what are they bound to? For example, can you just change the parent combo box field manually without any problems? How does this affect the data in both of the forms if you do that?

    Using: Office 2010/Win7 (work) Office 2010/Win7 (home)

    You are rich in proportion to the number of things you can let alone.
    -- Henry David Thoreau

  3. #3
    Board Regular
    Join Date
    Jul 2010
    Posts
    399
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Changing Values of Text Box on Main Form from Sub Form

    the write conflict is probably because you are saving the record after updating it with code instead of before.

    try saving it first:

    Code:
    Private Sub cmbSubCombo_AfterUpdate()
    If Me.SubCombo.Value = 1 Then
    Me.Parent.Dirty = False
    Me.Parent!cmbMainCombo.Value = 1
    Me.Parent!cmbMainCombo.Locked = True
    End If
    End Sub

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •