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

you may have entered and operand without an operator

P: 1
I am having trouble trying to get and expression to work. I keep getting the same syntax error, you may have entered and operand without an operator. What i am trying to do: one field contains a number which start with either a 1, 2, 3, or 4 and I want the previous field to automatically fill in a correct item based on what the number starts with.

This is the expression that I was trying to modify
Expand|Select|Wrap|Line Numbers
  1. > IIF(Left[Number;1]=1,"DDA",IIF(left[Numbe;1]=2,"SAV","IIF(left[Number;1]=3,"CD",IIF(left[Number;1]=4,"LAS")))))))
Any suggestions as to what I am doing wrong. I am new to all of this.

Thank you for any feedback
Jun 4 '09 #1
Share this Question
Share on Google+
5 Replies


Expert 100+
P: 1,287
I don't think it's a good practice to have a semicolon in the name of a field or control, but also Number is missing an 'r' in the second IIf. This may or may not be the result of retyping your code.
Jun 4 '09 #2

missinglinq
Expert 2.5K+
P: 3,532
That was my first thought too, Chip! But he's using the semi-colon to separate the field name and the 1 in the function!


Where to start?

First off, unless you're using some strange Regional Settings, the comma is usually used to seperate the arguments in a function, not a semi-colon. You also have to use parentheses when using a function, so you need

Left(Number,1)

not

Left[Number;1]


In your second IIF() you've misspelled your field, leaving off the final "r."

IIF(left[Numbe;1]=2

and lastly, Number is a Reserved Word in Access and shouldn't be used as a field/control name.

There may be other errors; these serpentine nested IIF() construct are always hard to debug and really should be avoided.

Welcome to Bytes!

Linq ;0)>
Jun 4 '09 #3

Expert 100+
P: 1,287
Oh you're right, that's not supposed to be a field name. The brackets threw me off.
Jun 4 '09 #4

NeoPa
Expert Mod 15k+
P: 31,709
On top of what's already been said you have an extraneous (extra) " before your third IIF.

Also, you don't say where this expression is supposed to go. In VBA? In SQL?

Lastly, please check this out.
It is always a good idea to ensure that variable name checking is enabled, AND your code compiles (at least compilation has been attempted), before submitting a question (Require Variable Declaration).

This avoids asking questions which are much more easily resolved on your own PC than on a forum.

To ensure variable name checking is enabled for all new modules, go to - Tools / Options / Editor (from the VBA Editor window) and set Require Variable Declaration to True (checked). For existing modules, ensure that the Option lines at the very top include :
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
Jun 4 '09 #5

NeoPa
Expert Mod 15k+
P: 31,709
Oh, and you seem to have 3 more closing parentheses than opening ones.

Welcome to Bytes!
Jun 4 '09 #6

Post your reply

Sign in to post your reply or Sign up for a free account.