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
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Expr: iif([status] like "*/*",Right(Trim([Status]),Len(Trim([Status]))-InStr(1, _
[Status],"/")), [status])

Is this what you're wanting?

Phil...
 
Upvote 0
Hi,

Thanks for your response.

With your code I am still getting #ERROR from the fields that do not have a "/" in them.

Steve
 
Upvote 0
Is there perhaps another data condition that needs to be tested for? Are there any null or blank records?

Phil...
 
Upvote 0
Hi,

No blank or null fields. Status is a required field in the DB. Its a text field (just checked). Just can't get anything to the left of the "/" when the "/" doesn't exist in the record. Like I said, function works great when the "/" is present in the record.

Thx.

Steve
 
Upvote 0
Using this:
Expr: IIf([status] Like "*/*",Right(Trim([Status]),Len(Trim([Status]))-InStr(1,[Status],"/")),[status])
I get this: <TABLE border=1 cellSpacing=0 bgColor=#ffffff><CAPTION>Query1</CAPTION><THEAD><TR><TH bgColor=#c0c0c0 borderColor=#000000>Expr</TH></TR></THEAD><TBODY><TR vAlign=top><TD borderColor=#d0d7e5>Qualified</TD></TR><TR vAlign=top><TD borderColor=#d0d7e5>Swing</TD></TR><TR vAlign=top><TD borderColor=#d0d7e5>Commit</TD></TR><TR vAlign=top><TD borderColor=#d0d7e5>Swing</TD></TR><TR vAlign=top><TD borderColor=#d0d7e5>Trans</TD></TR><TR vAlign=top><TD borderColor=#d0d7e5>Commit</TD></TR></TBODY><TFOOT></TFOOT></TABLE>

Is this what you're after?

Phil...
 
Upvote 0
ok, that got rid of the "/". Thanks ! Now there is a different problem. Any status that does have the "/" in it gives me the text to the right of the "/"

For example:

Fallout/Commit gives me "Commit"
Fallout gives me "Fallout"
Swing/Commit gives me "Commit"
Discovery gives me "Discovery"

Getting closer !!

Steve
 
Upvote 0

Forum statistics

Threads
1,224,594
Messages
6,179,794
Members
452,943
Latest member
Newbie4296

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