IF THEN ControlSource is

  • Thread starter Thread starter s4
  • Start date Start date
S

s4

Hi,

Just wondering if anyone knows a way to change a textbox's control on a
report depending on another text box's contents.
Like if text1 = this then text2.controlsource = this
if text1 = that then text2.controlsource = that
(I don't actually want text2 to say whatever's in text 1)
Thanks
 
S4,

I have seen problems with trying to change the Control Source of a
textbox on the fly. I believe it will be a better solution to have 2
textboxes, overlaid on top of each other, one with Control Source [this]
and the other [that], and you toggle the Visible property of these
controls based on the value of Text1. Code might be like this:

Me.This.Visible = Me.Text1 = "this"
Me.That.Visible = Me.Text1 = "that"
 
Good idea,
Thanks

Steve Schapel said:
S4,

I have seen problems with trying to change the Control Source of a
textbox on the fly. I believe it will be a better solution to have 2
textboxes, overlaid on top of each other, one with Control Source [this]
and the other [that], and you toggle the Visible property of these
controls based on the value of Text1. Code might be like this:

Me.This.Visible = Me.Text1 = "this"
Me.That.Visible = Me.Text1 = "that"

--
Steve Schapel, Microsoft Access MVP
Hi,

Just wondering if anyone knows a way to change a textbox's control on a
report depending on another text box's contents.
Like if text1 = this then text2.controlsource = this
if text1 = that then text2.controlsource = that
(I don't actually want text2 to say whatever's in text 1)
Thanks
 
s4 said:
Hi,

Just wondering if anyone knows a way to change a textbox's control on
a report depending on another text box's contents.
Like if text1 = this then text2.controlsource = this
if text1 = that then text2.controlsource = that
(I don't actually want text2 to say whatever's in text 1)
Thanks

No need to change the ControlSource. Just use IIf() in the ControlSource.
 
Back
Top