By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,449 Members | 921 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,449 IT Pros & Developers. It's quick & easy.

Help with a report field

P: n/a
Can you write an if satement in a control source fild of a text box to
do the following. I am trying to get it to look at another field in the
form and depending upon what text is in that field it would return a
value. So if in the Site text box says rv1 or rv2 etc I want the other
field to show $20. Or if it has T101 or T102 etc. the the other field
would show $10. I think this should be possible. I don't know if I'm
trying to doit in the wrong area or if my syntx for the if statement is
just wrong. Any help would be apperciated.

Thanks
Dan

Dec 15 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
The syntax is Forms!frmSecondFormName!txtTextBoxName.

You would put it in an IIf statement like so:

Iif(Forms!frmSecondFormName!txtTextBoxName="rv1", "$20", "")

Dec 15 '05 #2

P: n/a
Im an idiot I meant a report would it still work if change report etc.

Dec 15 '05 #3

P: n/a

"deercreek" <da*@deercreekcg.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Can you write an if satement in a control source fild of a text box to
do the following. I am trying to get it to look at another field in the
form and depending upon what text is in that field it would return a
value. So if in the Site text box says rv1 or rv2 etc I want the other
field to show $20. Or if it has T101 or T102 etc. the the other field
would show $10. I think this should be possible. I don't know if I'm
trying to doit in the wrong area or if my syntx for the if statement is
just wrong. Any help would be apperciated.


It's a little difficult to give you a specific answer without knowing what
the "etc" is in "rv1 or rv2 etc" and "or if it has T101 or T102 or etc".
It's also difficult to tell you whether your syntax for the statement is
wrong unless we know (1) where the statement occurs, in the Control Source,
or in VBA event code and, if the latter, what event and (2) what statement
you are using that doesn't work.

Steve has shown you an example that can be changed to your form and control
names to work for one value, but it seems you want something more than just
one value.

Larry Linson
Microsoft Access MVP

Larry Linson
Microsoft Access MVP
Dec 15 '05 #4

P: n/a
I got it to work for a specific value if I wanted to use a wilcard so
it will show value for anything that starts with rv can you tell me
what the wild card would be?

Dec 15 '05 #5

P: n/a
I tired the "*" dosn't work!

Dec 15 '05 #6

P: n/a
Iif(Left(Forms!frmSecondFormName!txtTextBoxName, 2)="rv", "$20", "")

Dec 15 '05 #7

P: n/a
That works but how to I tie it altogether so I can return differnt
values depending on the prefix?

Dec 15 '05 #8

P: n/a
deercreek, you could answer your own question with just a little bit of
effort. I'm willing to help you out if you're willing to try and think
for yourself.

That being said, investigate the IIf statement in Access help. The
syntax is IIf(expression, value if true, value if false). You can nest
IIf statements, so you could have, for instance:
if(Left(Forms!frmSecondFormName!txtTextBoxName, 2)="rv", "$20",
IIf(Left(Forms!frmSecondFormName!txtTextBoxName, 2)="T1", "$10", "No
value declared"))

Every individual value you wish to check for requires another IIf
statement.

Dec 15 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.