Control source dependent upon other control value

  • Thread starter Thread starter Joan
  • Start date Start date
J

Joan

Hi,

I think I posted this to the wrong newsgroup the first time, so I am
reposting this to the formscoding newsgroup.

I have a subform (in continuous forms view) upon which the control source
of one of its' controls is dependent upon the value of another control on
the form. For instance I want the control source of this control to be
ReturnedSalePrice2 if [Returned] Is Not Null, otherwise the control source
should be [SalesPrice]. I tried putting the following code in the subform's
OnLoad event but it doesn't work. I get #Name? in the control instead.
Should this not be on the OnLoad event of the subform? What am I doing
wrong?


Private Sub Form_Load()
If Not IsNull(Me.Returned) Then
Me.SalesPrice.ControlSource = ReturnedSalePrice2
Else
Me.SalesPrice.ControlSource = SalesPrice
End If
End Sub


Joan
 
Try putting the field names to the right of the equal sign
in quotes. I think VB expects this to be a string
variable.

So the first option would be:

Me.SalesPrice.ControlSource = "ReturnedSalePrice2"

Give that a try...

Chuck
 
Thanks, Chuck.

Joan


Try putting the field names to the right of the equal sign
in quotes. I think VB expects this to be a string
variable.

So the first option would be:

Me.SalesPrice.ControlSource = "ReturnedSalePrice2"

Give that a try...

Chuck
-----Original Message-----
Hi,

I think I posted this to the wrong newsgroup the first time, so I am
reposting this to the formscoding newsgroup.

I have a subform (in continuous forms view) upon which the control source
of one of its' controls is dependent upon the value of another control on
the form. For instance I want the control source of this control to be
ReturnedSalePrice2 if [Returned] Is Not Null, otherwise the control source
should be [SalesPrice]. I tried putting the following code in the subform's
OnLoad event but it doesn't work. I get #Name? in the control instead.
Should this not be on the OnLoad event of the subform? What am I doing
wrong?


Private Sub Form_Load()
If Not IsNull(Me.Returned) Then
Me.SalesPrice.ControlSource = ReturnedSalePrice2
Else
Me.SalesPrice.ControlSource = SalesPrice
End If
End Sub


Joan


.
 
Back
Top