473,387 Members | 1,502 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Help with Query ... If greater then insert... Syntax Error

I am a somewhat Novice Access user and have limited rather zilch programming skills.

Problem:

I am receiving the following error: "The expression you entered contains invalid syntax'

In the query, I have built several fields containing calculations. In one of the fileds, I am trying to have the field insert one value, if the current value is greater than the other value. For example - if AvgEarn equals 9 and Expected is 8, I want to have the 8 placed in the field. I am trying the following and have tried to state this a few other ways as well.


Points: IIf ([AvgEarn]>[Log]![Expected], [Log]![Expected]


Thank you in advance for your assistance and attention to my question!

Jennifer
Feb 1 '07 #1
8 3367
Rabbit
12,516 Expert Mod 8TB
I am a somewhat Novice Access user and have limited rather zilch programming skills.

Problem:

I am receiving the following error: "The expression you entered contains invalid syntax'

In the query, I have built several fields containing calculations. In one of the fileds, I am trying to have the field insert one value, if the current value is greater than the other value. For example - if AvgEarn equals 9 and Expected is 8, I want to have the 8 placed in the field. I am trying the following and have tried to state this a few other ways as well.


Points: IIf ([AvgEarn]>[Log]![Expected], [Log]![Expected]


Thank you in advance for your assistance and attention to my question!

Jennifer
Assuming you pasted everything correctly, then your syntax is indeed wrong.

It should be:
Points: iif([AvgEarn]>[Log]![Expected],[Log]![Expected],"Value if Expected equals or exceeds AvgEarn")

The syntax of iif is iif(Expression, Value if true, Value if false)
1) You forgot to include a value if false.
2) You forgot to close the function.
Feb 1 '07 #2
ADezii
8,834 Expert 8TB
I am a somewhat Novice Access user and have limited rather zilch programming skills.

Problem:

I am receiving the following error: "The expression you entered contains invalid syntax'

In the query, I have built several fields containing calculations. In one of the fileds, I am trying to have the field insert one value, if the current value is greater than the other value. For example - if AvgEarn equals 9 and Expected is 8, I want to have the 8 placed in the field. I am trying the following and have tried to state this a few other ways as well.


Points: IIf ([AvgEarn]>[Log]![Expected], [Log]![Expected]


Thank you in advance for your assistance and attention to my question!

Jennifer
I'm not really sure what you are looking for here, but what is relevant is the Syntax:
IIF(<expression>, <value if True>, <value if False>)

'If AvgEarn is greater than Expected, then the value in the [Expected] Field is returned and placed in the [Points] Field. For any other condition, the value in the [AvgEarn] Field is placed in [Points]. Hope this helps.
Expand|Select|Wrap|Line Numbers
  1. Points: IIf([AvgEarn]>[Expected],[Expected],[AvgEarn])
Feb 2 '07 #3
Thank you for your assistance. In the field, as suggested, I typed in the following:

Points: IIf([AvgEarn]>[log]![Expected],[Log]![Expected],[AvgEarn])

Total: I selected Expression, tried the Total field blank and selected others. Each time, I received the following error:



You tried to execute a query that does not include the specified expression 'IIf(/ >[log]![Expected],[Log]![Expected],[AvgEarn])' as part of an aggregate function.




Do you have any suggestion as to what I should try now??

Once again, thank you so much for your assistance!!!

PS - I am using Access 2000
Feb 2 '07 #4
Thank you Thank you Thank you!!!!!!! with extra chocolate sauce and everything else good in this world!

I am all set now and ready to conquer the task at hand. Once again, thanks for your help you have been a life saver... or well at least a job saver!!!


Thanks again!
Feb 2 '07 #5
Rabbit
12,516 Expert Mod 8TB
Does this mean you have the other problem solved?
Feb 2 '07 #6
NeoPa
32,556 Expert Mod 16PB
No, I think she's just happy after eating a bowlful of chocolate :D
I think we can consider this one closed.
Feb 4 '07 #7
No, I think she's just happy after eating a bowlful of chocolate :D
I think we can consider this one closed.
The issue is closed. I do have another problem regarding counting a data in a field that is of a certain value ... but I am looking through previous posts to hopefully solve the problem first. If not, I'll be a repeat customer!!

Thanks again!
Feb 5 '07 #8
NeoPa
32,556 Expert Mod 16PB
We'd love to have you back Jenn.
It sounds like a problem we've dealt with before, but as long as it's clearly explained, we're happy to do it again if you need it.
BTW my address for sending chocolate to is :
........ :)
Feb 5 '07 #9

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

Similar topics

15
by: Jack | last post by:
I have a text file of data in a file (add2db.txt) where the entries are already entered on separate lines in the following form: INSERT INTO `reviews` VALUES("", "Tony's", "Lunch", "Great...
28
by: stu_gots | last post by:
I have been losing sleep over this puzzle, and I'm convinced my train of thought is heading in the wrong direction. It is difficult to explain my circumstances, so I will present an identical...
8
by: Tcs | last post by:
I've been stumped on this for quite a while. I don't know if it's so simple that I just can't see it, or it's really possible. (Obviously, I HOPE it IS possible.) I'm trying to get my queries...
2
by: Bob Alston | last post by:
I am going blind tonight but I cannot figure out the error. I get a syntax error from this sql statement, being run via vba in access 2003 insert into tbl_Volunteer_Donor in...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
1
by: teddymeu | last post by:
Hi Guys, trying to bulk insert a csv file into my SQL database from an asp.net vb web app/form page that the user uploads, my problem is that im new to all this and although the SQL statement...
9
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result...
6
by: ewpatton | last post by:
Good day, I've been trying to work with SQL and an Access database in order to handle custom user profiles. I haven't had any trouble reading from my database, but inserting new entries into...
11
by: troy_lee | last post by:
I have two fields on a form. These two fields' values are based on an expression and represent a date range. I need to create a SQL statement that will use the returned values of these two fields...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.