Go Premium for a chance to win a PS4. Enter to Win

x
?
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
Medium Priority
?
854 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 49

Expert Comment

by:Dale Fye
ID: 39747424
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
ID: 39747538
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 49

Accepted Solution

by:
Dale Fye earned 1000 total points
ID: 39748034
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 1000 total points
ID: 39748269
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
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…

877 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