Solved

Access SQL qurey error

Posted on 2010-11-19
9
268 Views
Last Modified: 2012-05-10
Hello I get this error on the below select statment. Your help is apperciated in advance.

Undefined function 'chatindex' in expression

select  LEFT(products.number, charindex('.',products.number)) from products
0
Comment
Question by:ubsmail
[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
  • 5
  • 4
9 Comments
 
LVL 13

Expert Comment

by:Torrwin
ID: 34175425
Try:

SELECT LEFT(Products.Number, InStr(1, Products.Number, '.'))
FROM Products
0
 
LVL 13

Expert Comment

by:Torrwin
ID: 34175445
Actually, that may include the period in the selection, so you may need to add a -1 to the position:

SELECT LEFT(Products.Number, (InStr(1, Products.Number, '.')-1))
FROM Products
0
 

Author Comment

by:ubsmail
ID: 34175465
Looks good any way to handel the error if it does not have a "."

Expr1000
#Error
1ABMJK0005
1ABMJK0005
1ABMJK0005
1ABMJK0005
#Error
1ABMJK0006
1ABMJK0006
1ABMJK0006
1ABMJK0006
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 13

Expert Comment

by:Torrwin
ID: 34175660
You could use a CASE statement, something like:

SELECT CASE WHEN (InStr(1, Products.Number, '.') > 0) THEN LEFT(Products.Number, (InStr(1, Products.Number, '.')-1)) ELSE Products.Number) END
0
 

Author Comment

by:ubsmail
ID: 34175759
Thanks Torrwin

I got this error:

Syntax error (missing operator) in qury experrsion 'CASE WHEN (Instr(1, Products.Number, '.') >0)........
0
 
LVL 13

Expert Comment

by:Torrwin
ID: 34175853
Oops, looks like a missing parenthesis:

SELECT CASE WHEN ((InStr(1, Products.Number, '.') > 0) THEN LEFT(Products.Number, (InStr(1, Products.Number, '.')-1)) ELSE Products.Number) END
0
 

Author Comment

by:ubsmail
ID: 34175869
Same error accesss is picky
0
 
LVL 13

Accepted Solution

by:
Torrwin earned 500 total points
ID: 34175953
If you're running it in Access,  you could use the IIF function instead:

SELECT IIF(InStr(1, Products.Number, '.') > 0, LEFT(Products.Number, (InStr(1, Products.Number, '.')-1)), Products.Number)
FROM Products
0
 

Author Closing Comment

by:ubsmail
ID: 34176139
Thanks!
0

Featured Post

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

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

Suggested Solutions

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
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.
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…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

740 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