J
Joan
I am having difficulty with a subform's textbox control source. This
subform is on more than one form. On one of the main forms, AddLitter, the
control source for the subform's textbox is:
[Forms]![AddLitter]![Littershot Subform]![Vaccine].Column(2). The textbox
is called [Mfg] and is dependent upon the vaccine that the user selects in
the Vaccine combo box on the subform. My problem comes is when I open a
different main form with this subform on it. The textbox shows Name?
because the control source is wrong. I have tried resetting the control
source in the subform's OnCurrent event but am having much difficulty. Here
is a sample of my code:
Private Sub Form_Current()
If Me.Parent.Name = "AddLitter" Then
If Me.Vaccine.AfterUpdate Then
Me.Mfg.ControlSource = Me.Vaccine.Column(2)
'ElseIf Me.Parent = "EditLitter" Then
'Me.Mfg.ControlSource = Me.Vaccine.Column(2)
End If
End If
End Sub
I get a type mismatch error on the ' If Me.Vaccine.AfterUpdate Then' line.
Would appreciate someone explaining how best to change the control source of
a control in a subform programmaically. Am I on the right track? As in
right event, and event of the right form, etc? And why am I getting a type
mismatch error in my code?
Joan
subform is on more than one form. On one of the main forms, AddLitter, the
control source for the subform's textbox is:
[Forms]![AddLitter]![Littershot Subform]![Vaccine].Column(2). The textbox
is called [Mfg] and is dependent upon the vaccine that the user selects in
the Vaccine combo box on the subform. My problem comes is when I open a
different main form with this subform on it. The textbox shows Name?
because the control source is wrong. I have tried resetting the control
source in the subform's OnCurrent event but am having much difficulty. Here
is a sample of my code:
Private Sub Form_Current()
If Me.Parent.Name = "AddLitter" Then
If Me.Vaccine.AfterUpdate Then
Me.Mfg.ControlSource = Me.Vaccine.Column(2)
'ElseIf Me.Parent = "EditLitter" Then
'Me.Mfg.ControlSource = Me.Vaccine.Column(2)
End If
End If
End Sub
I get a type mismatch error on the ' If Me.Vaccine.AfterUpdate Then' line.
Would appreciate someone explaining how best to change the control source of
a control in a subform programmaically. Am I on the right track? As in
right event, and event of the right form, etc? And why am I getting a type
mismatch error in my code?
Joan