Changing Values of Text Box on Main Form from Sub Form

CPGDeveloper

Board Regular
Joined
Oct 8, 2008
Messages
189
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:

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
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?
 
Upvote 0
the write conflict is probably because you are saving the record after updating it with code instead of before.

try saving it first:

Code:
[COLOR=#333333]Private Sub cmbSubCombo_AfterUpdate()[/COLOR]
[COLOR=#333333]If Me.SubCombo.Value = 1 Then
[/COLOR][COLOR=#333333]Me.Parent.Dirty = False
[/COLOR][COLOR=#333333]Me.Parent!cmbMainCombo.Value = 1[/COLOR]
[COLOR=#333333]Me.Parent!cmbMainCombo.Locked = True[/COLOR][COLOR=#333333]
[/COLOR][COLOR=#333333]End If[/COLOR]
[COLOR=#333333]End Sub[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,619
Latest member
Shiv1198

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top