Private Sub OptItemType_Enter()
did you copy the posted code directly from your form module? if so, this
code is running on the option group control's Enter event, not the
AfterUpdate event. if the bound field of the control is empty when you enter
the control, then of course the code will not assign a SourceObject.
if you're using the form for adding new records, AND reviewing/updating
existing records, you should have the code running on both the option group
control's AfterUpdate event, and the form's Current event. the posted code
itself looks fine to me, assuming you got all the "names" right. suggest you
put it in a separate procedure, such as
Private Sub isSource()
Select Case OptItemType
etc, etc, etc
End Sub
then call the procedure from the control AfterUpdate event and form Current
event, as
Private Sub OptItemType_AfterUpdate()
isSource
End Sub
and
Private Sub Form_Current()
isSource
End Sub
btw, you need to make sure the correct value is entered in the
ChildLinkFields property in the subform control (frame), when you set the
SourceObject.
hth
beejsnyder said:
I feel like I should clarify my question here.
I have an Option Group called "Department" and bound to a field in the
table called "Dept.". Within the Option Group I have three radio buttons,
for Custom, Factory and Gemstones. I have subforms created with the same
three names. I have a subform frame called "DeptSubform". And, finally, I
have the following code in the AfterUpdate event for the Option Group called
"Department":
Private Sub OptItemType_Enter()
Select Case OptItemType
Case 1
Me!DeptSubform.SourceObject = "Custom"
Case 2
Me!DeptSubform.SourceObject = "Factory"
Case 3
Me!DeptSubform.SourceObject = "Gemstones"
Case Else
MsgBox "What Department?"
End Select
End Sub
My goal is that I will click on the button called "Custom" and within the
subform frame the subform called "custom" will be displayed, and the same
cause-and-effect for the other two radio buttons and their corresponding
subforms. But right now when I click on a radio button it DOES put the
appropriate value in the table (yay!) but no subform is displayed. I feel
VERY close but that I probably am misunderstanding some aspect of the event
code.
Help? And thanks both in advance and after!
-beejsnyder
put the appropriate subform? I have created the three sub-forms and have
set up the option group w/ the values and the event procedure for after
update. But how to I tell the original form "display SubformCustom here
because option 1 was selected?"