Solved

Undefined Function ‘CHARINDEX’ in expression’ Error

Posted on 2007-03-21
6
1,455 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

728 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