TextBox ControlSource

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
 
B

Brendan Reynolds

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.
 
W

Warrio

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.
 
L

LWendel

Is the field you are using a True/False field ? If so the code should be 0
for false and -1 for true.
 

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