Text Box If Then help

FannyPerpendicular

New member
Local time
Today, 14:22
Joined
Jul 27, 2011
Messages
3
Hello,
I have an unbound Text Box [D] in an Access 2007 report. The results of that Text Box are based on information entered in 3 other Text Boxes. I've tried to build an expression but end up with errors. I'm thinking VBA might be a better way to go. I don't have much in the way of VBA knowledge.

Here's the criteria I'm trying to get to work.

If [A] < 65 And = "RED" And [C] <= #1/31/1991# Then [D] = DateAdd ('m',15,[C])
If [A] < 65 And = "BLUE" And [C] between #2/1/1991# & #1/1/1995# Then [D] = DateAdd ('m',21,[C])
If = "GREEN" Then [D] = DateAdd ('m',36,[C])

It goes on from there but I think I can add more once I get the hang of what needs to be done.
 
You can't use If..Then in the Control Source of a text box. You could use the IIf function in the Control Source of [D], something like;

=IIf([A] < 65 And = "RED" And [C] <= #1/31/1991#, DateAdd ('m',15,[C]),IIf([A] < 65 And = "BLUE" And [C] between #2/1/1991# And #1/1/1995#, DateAdd('m',21,[C]), DateAdd ('m',36,[C])))

but if you have a lot of conditions, or if the date parameters will change often, then this approach would be difficult to manage.
 
Thanks! I ended up creating each Iif criteria seprately and then joined the. I managed to get all 7 in and working!:D
 

Users who are viewing this thread

Back
Top Bottom