Conditional Expression.

RycherX

Registered User.
Local time
Today, 10:10
Joined
Dec 17, 2009
Messages
16
In an "embedded macro" under the "condition" column, how long can an expression be? I have the following expression that always gets shortened. I need this conditioned process before triggering an action.
If I can't change the length of the expression set by Access, is there an alternative? I would like to continue working with "embedded macros".


(Trim([Forms]![PRM7]![TextBox1] & " ")<>"") And
(Trim([Forms]![PRM7]![TextBox1] & " ")<>"" And Trim([Forms]![PRM7]![TextBox2] & " ")<>"") And
(Trim([Forms]![PRM7]![TextBox1] & " ")<>"" And Trim([Forms]![PRM7]![TextBox2] & " ")<>"" And Trim([Forms]![PRM7]![TextBox3] & " ")<>"")
 
Surely anything concatenated with a space will never be equal to the Null String.
As far as I can see this condition will always return True.
 
Not if TextBox contains text.
 
If the text box contains text, then concatenating that text with a space will definitely not be equal to a Null String. The result is True.

Concatenating anything (including nothing) with a space will always result in at least a space meaning the result will never be a Null String. Hence the condition will always be true regardless of the content of any of the controls.

You need to rethink what you are trying to test.
 
I think you've run into one of the reasons none of the "professionals" on this site like macros. We don't like our stuff to be changed.

I'm guessing, though, that Access has shortened it for a reason. Most of your conditional statement is redundant. Re-read the rules of "and"ing together conditions. The correct statement would be:
Code:
Trim([Forms]![PRM7]![TextBox1] & " ")<>"" And Trim([Forms]![PRM7]![TextBox2] & " ")<>"" And Trim([Forms]![PRM7]![TextBox3] & " ")<>""

BTW, Trim(" ") is equal to "", so if your controls are NULL, this statement will return "False". It is not clear to me why that has become the issue, unless you've edited the OP.
 
Ah George has seen my error. I misread the location of the bracket in the Trim function.
Sorry about that. Tired eyes.
 
An honest mistake. Now if you'll only forgive all the mistakes I make!

But on further consideration, I'm wondering why RycherX is posting this? What is Access shortening his condition to? Is it working or not? If not, what are the conditions under which it isn't working and what is the expected result?
 
An honest mistake. Now if you'll only forgive all the mistakes I make!

There is not a serious user here who has never posted an error. Not just from misreading but real misunderstandings. Sometime it is because we should be in bed. Sometime from not being familiar with different versions. Some are myths and phobias accumulated from early efforts negotiatiing the jungle of learning that is Access.

We can only hope that someone spots our mistakes. Lucky for me I am at a level where there are many who can see where I go wrong. One thing for sure there is learning for everyone here.

It happens all levels from simple things we never realised could be done through to the real benders where ordinary folk like you or me can barely comprehend the context of the discussion let alone the detail. I read a discussion between Banana and Leigh Purvis today in that category. I remain in awe of developers at that level of knowledge yet both demonstate room to expand their understanding.

http://www.access-programmers.co.uk/forums/showthread.php?t=187687

I love this place.
 

Users who are viewing this thread

Back
Top Bottom