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
813 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)
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 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 250 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 250 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

830 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