TextBox ControlSource

  • Thread starter Thread starter Warrio
  • Start date Start date
W

Warrio

Hello!!

I have to set (by code) the control source of a textbox and I use the
following code:

myTextBox.ControlSource = "IIf(1=1;'True';False')

the result should be 'True'

but when I run this statement, Access says "The expression you entered
contains invalid syntax"
However, the expression works if I type it (by hand) into the textbox
control

Does anyone knows why I can't do that by code?

Thanks for any suggestion
 
Should be more like ...

Me!txtTest.ControlSource = "=IIf(1=1,'True','False')"

.... you're missing the '=' in front of the 'IIf', and the apostrophe in
front of 'False'.

Ignore the fact that I'm using commas and you're using semi-colons, that's
not an error, that's just because we're using different international
settings.
 
Thanks for the help!!
it's great!!

Brendan Reynolds said:
Should be more like ...

Me!txtTest.ControlSource = "=IIf(1=1,'True','False')"

... you're missing the '=' in front of the 'IIf', and the apostrophe in
front of 'False'.

Ignore the fact that I'm using commas and you're using semi-colons, that's
not an error, that's just because we're using different international
settings.
 
Is the field you are using a True/False field ? If so the code should be 0
for false and -1 for true.
 
Back
Top