Getting #ERROR when extracting text string from query field

sbecker61

Board Regular
Joined
Dec 29, 2009
Messages
52
Using Access 2007. I have a field called "Status" in my DB that gives the status of an opportunity in a sales cycle. Status has values like:

Qualified
Qualifed/Swing
Commit
Commit/Swing
Trans
Trans/Commit

I want to write a simple query field to extract all text to the left of the "/" in the field. The challenge I have is that I get a #ERROR when the slash doesn't exist in the record. Here is my code:

Expr: Right(Trim([Status]),Len(Trim([Status]))-InStr(1, _
[Status],"/"))

How do I write the expression so that when the "/" isn't there, I just get the record back and not the #ERROR message.? Works great btw when the "/" is in the record.

Thanks.

Steve
 
Hi,

Me again. Your function works wonderful inside of Access. When I use Excel 2007 to run the query that contains the function, the function doesn't work on the Excel side. I've checked and re-checked and the function isn't working in Excel. Like I said, it works great when I am in Access 2007. It just doesn't run in Excel. Any idea as to why? I've googled galore with no answers.

Basically what I get back is the entire value of "Status". Its like the function never executed.

I am doing nothing fancy in Excel. I just run the query from Excel.

Thanks.

Steve
 
Upvote 0

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Here is my code:

Status_Simple: IIf([status] Like "%/%",Left(Trim([Status]),InStr(1,[Status],"/")-1),[status])

This messes up the Access query now. Isn't parsing the "/" anymore.

Thx.

Steve
 
Upvote 0
% is the standard way of doing it
its the way oracle, mysql and ms sql server do it

* is non standard
its the way access does it

excel follows the standard

that's just the way it is

you could try this instead
Code:
IIf
(
  InStr(1, [Status], "/") > 0 
  Left
  (
    Trim([Status]),
    InStr(1, [Status], "/") - 1
  ),
  [status]
)
 
Upvote 0

Forum statistics

Threads
1,225,170
Messages
6,183,320
Members
453,155
Latest member
joncaxddd

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top