Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

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
?
848 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 48

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 48

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

Application Discovery Service in AWS

In the era of the cloud, customers migrating away from their existing on-premise infrastructure. This requires lots of planning, strategies, and effort to identify their existing resources and determine how best to migrate.  Datacenter migrations happen in four phases -

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
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…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

715 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