424,842 Members | 2,186 Online
Need help? Post your question and get tips & solutions from a community of 424,842 IT Pros & Developers. It's quick & easy.

"The expression you entered contains invalid syntax."

 P: 1 Can someone please help me? I am making a system through Microsoft Access 2016 for school and I am having trouble writing this expression. If you could help me ASAP that would be amazing. The expression is so that if the field "Maximum Capacity" is equal to 1, then the value in the field "Private Lesson" will equal to Yes or True. This is what I have made so far but I don't understand how to write expressions so could anyone help me? Expand|Select|Wrap|Line Numbers = True IIf( ([Maximum Capacity] =1, <1=False ) When I try to enter the code in the builder, the error message says "The expression you entered contains invalid syntax. You may have entered an operator, such as the + operator, in an expression without a corresponding operand." Thank you! Dec 17 '18 #1

tam21

Welcome to Bytes!

Expand|Select|Wrap|Line Numbers
1. = ([Maximum Capacity] = 1)
Hope this hepps!

8 Replies

 Expert Mod 2.5K+ P: 3,158 tam21 Welcome to Bytes! Your expression should be Expand|Select|Wrap|Line Numbers = ([Maximum Capacity] = 1) Hope this hepps! Dec 17 '18 #2

 Expert Mod 15k+ P: 31,306 Perfect answer. Correct and succinct. Dec 17 '18 #3

 Expert 2.5K+ P: 2,932 You might want to look at the documentation for the IIF() function as well since it seems that you don't have a very good grasp on it. In this case, TwinnyFo is correct on the best option, but there are times when the IIF() function should be used (like if you wanted to return values other than True/False, like "Full/Empty"). MS Access IIF Function. So the syntax for your problem would be Expand|Select|Wrap|Line Numbers =IIF([Maximum Capacity] = 1, True, False) This is another way to skin your particular cat, but again, TwinnyFo's method is better because it is more succinct. I just share this for your educational benefit. Dec 18 '18 #4

 Expert Mod 15k+ P: 31,306 TwinnyFo: I think I learned these logical tricks from someone here on Bytes. Not sure if NeoPa recalls him or not.... ;-) In answer to the question behind your comment - Of course I both remember guiding you on this as well as - Yes, I'm monitoring all you post too, at least in the Access forum. @Seth. As a general rule people need very little help understanding `IIf()` and its usage. What is less obvious is returning the value from a simple logical statement. Twinny has already explained why that is often preferable to using more complicated syntax but if you need more then I remember explaining this more fully in a thread that Twinny was involved in. It was hard to find so I did it for you - Booleans and Conditional Code. Dec 19 '18 #7
 Expert Mod 15k+ P: 31,306 Righto. That all sounds good. I see why you gave the `IIf()` assistance ;-) Dec 21 '18 #9