Solved

Undefined Function ‘CHARINDEX’ in expression’ Error

Posted on 2007-03-21
6
1,423 Views
Last Modified: 2008-01-09
Hi All,

I need your assistance. I have the following SQL that works in SQL Query Analyser but it is not working on MS Access on the SQL section.

I received the following error:

Undefined Function ‘CHARINDEX’ in expression’

How could I fix this error? Can any one assist please?

Regards.


SELECT A.DOCID   AS 'Product ID',
 A.ProductCategory  AS 'Product Category',
 B.DOCID   AS 'Sales ID',
 B.SalesCategories  AS 'Sales Categories',
B.SalesName,
B.SalesYear,
 A.ProductAvailability   AS ' ProductAvailability '
FROM  Product A,
 Sales B
WHERE A.DOCIDPP = B.DocID
AND CHARINDEX(A.ProductCategory,B.SalesCategories) = 0
0
Comment
Question by:jose11au
[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
  • 3
  • 2
6 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 18769353
SQL Server and MS Access have 2 different sets of syntax. although most things are similar or even identical, not everything is.


SELECT A.DOCID   AS 'Product ID',
 A.ProductCategory  AS 'Product Category',
 B.DOCID   AS 'Sales ID',
 B.SalesCategories  AS 'Sales Categories',
B.SalesName,
B.SalesYear,
 A.ProductAvailability   AS ' ProductAvailability '
FROM  Product A,
 Sales B
WHERE A.DOCIDPP = B.DocID
AND INSTR(0, A.ProductCategory , B.SalesCategories ) = 0

now, this looks like your field b.salescategory contains a comma-delimited list of the product categories...
if that is the case, you should DEFINITIVELY change your table design, and make an intermediate table !
0
 
LVL 75
ID: 18769356
CHARINDEX .... There is no such function in Access / VBA.

What is it supposed to do?

mx
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18769357
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 250 total points
ID: 18769371
Thanks angel ... appears to be similar to InStr() ... so ... how about this:

SELECT A.DOCID AS ['Product ID'], A.ProductCategory AS ['Product Category'], B.DOCID AS ['Sales ID'], B.SalesCategories AS ['Sales Categories'], B.SalesName AS Expr1, B.SalesYear AS Expr2, A.ProductAvailability AS [' ProductAvailability ']
FROM Product AS A, Sales AS B
WHERE ((([A].[DOCIDPP])=[B].[DocID]) AND ((InStr([A].[ProductCategory],[B].[SalesCategories]))=0));

mx
0
 

Author Comment

by:jose11au
ID: 18775125
Hi Guys,

Thanks for your help. I you guys don't mind. I'll split the points.

Thanks.
0
 
LVL 75
ID: 18775269
A split was definitely in order ... no problem.  Thanks again angel.

mx
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

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.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

697 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