?
Solved

Undefined Function ‘CHARINDEX’ in expression’ Error

Posted on 2007-03-21
6
Medium Priority
?
1,498 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 1000 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 1000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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…
Suggested Courses

770 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