Solved

Access SQL qurey error

Posted on 2010-11-19
9
269 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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.
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.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

691 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