Solved

How to resolve an error in an Access 2003 query expression:  Function is not available in expressions in query expression 'IIf(isnumeric (clientacct),left(clientacct,3),"")'.  ?

Posted on 2013-12-30
4
772 Views
Last Modified: 2014-01-08
I am working with an Access 2003 application and when I execute the following query,
I get the error:

Function is not available in expressions in query expression 'IIf(isnumeric (clientacct),
left(clientacct,3),"")'.

Do you know how I can resolve this error?

INSERT INTO tblOpenItems
( Bank, Office, checkNum, refNo, [trans date], Type, [process date], Pending, AgeDays, T, Description,
amount, UserID, AuditDate, footnote, responsibility, rptID, [REPORT NAME] )
SELECT
OI_WRS.bankNum,
IIf(isnumeric(clientacct),left(clientacct,3),""),
IIf(isnumeric(clientacct),right(clientacct,6),clientacct),
OI_WRS.refNum,
OI_WRS.transMnth & "/" & OI_WRS.transDay & "/" & OI_WRS.transYr,
OI_WRS.transType,
OI_WRS.procMnth & "/" & OI_WRS.procDay & "/" & OI_WRS.processYr,
OI_WRS.pending,
OI_WRS.age*1,
OI_WRS.cr_db,
OI_WRS.descr,
IIf(sign="-",CDbl(OI_WRS.amount*(-1)/100),CDbl(amount)/100),
OI_WRS.userID,
OI_WRS.auditDt,
" ",
" ",
tblBanks.rptID,
tblBanks.[REPORT NAME]
FROM OI_WRS INNER JOIN tblBanks ON OI_WRS.bankNum=tblBanks.[Bank Code];
0
Comment
Question by:zimmer9
  • 2
4 Comments
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
Comment Utility
A couple of things I would check to start with.

1.  Check your references and ensure that none of them are MISSING.
2.  Does the [ClientAcct] field contain data for all fields, are there any NULLs?
3.  Are the fields [Trans date] and [Process date] actually date fields, or are they strings?  the way your SQL is written, it looks like they are strings.  If they are actually dates, you might want to try replacing:

OI_WRS.transMnth & "/" & OI_WRS.transDay & "/" & OI_WRS.transYr,

with:

DateSerial(OI_WRS.TransYr, OI_WRS.TransMnth, OI_WRS.TransDay)

and thendo the same for process month.

4.  I assume you are using Access as the front-end and are connecting to a Sybase database via ODBC, is that correct?  Are you running this query directly from Access or are you running it as a pass-through query to Sybase?

5.  What is "sign" in this line of code?

IIf(sign="-",CDbl(OI_WRS.amount*(-1)/100),CDbl(amount)/100)

is it a variable?  If so, where do you think that value is coming from?  In Access, there is a function sgn( ) which will return the sign associated with a value like sgn([somenumericfield]),  so is that a Sybase function?  If so, it will not be available in Access.
0
 

Author Comment

by:zimmer9
Comment Utility
To answer you second point, yes the [ClientAcct] field contains NULL values for some records.

If I replace the following 2 lines:

IIf(isnumeric(clientacct),left(clientacct,3),""),
IIf(isnumeric(clientacct),right(clientacct,6),clientacct),

with the next 2 lines

" ",
" ",

then the statement works fine.

How would you handle the possibilty of NULL values for the 2 IIf statements shown above?
0
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 250 total points
Comment Utility
I could not tell you what is wrong.  That syntax works just fine in a sample table that I built.  That is why I asked all of the other questions.  If you would answer them, we might be able to figure it out.

Did you check your references?

IIf(isnumeric(clientacct & ""),left(clientacct & "",3),""),
IIf(isnumeric(clientacct & ""),right(clientacct & "",6), clientacct),
0
 
LVL 13

Assisted Solution

by:alpmoon
alpmoon earned 250 total points
Comment Utility
First of all are you running that insert statement against Access database or Sybase database?

Sybase doesn't have that function. You need to replace it something else depending of Sybase product and version you are using if you need to execute that insert against a Sybase db.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now