Control source dependent upon other control value

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
 
G

Guest

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
 
J

Joan

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


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top