Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exclude certain information in a description on a report

Status
Not open for further replies.

papic1972

Technical User
Apr 10, 2003
209
AU
Hi all,

Does anyone know of a way to exclude part of a description in a field on a report.

E.g

If i have a description such as:

Bricks (Commons),

I want to exlude the description in brackets so that the description only displays as:

Bricks


Can anyone help?!

 
Is the bit you wish to exclude always in brackets and at the end of the line? If so, this should suit:

[tt]strDescription="Bricks (Commons)"
strShortDesc=Mid(strDescription,1,Instr(strDescription,"(")-1)[/tt]

 
Thanks Remou,

The bit i wish to exclude is always bracketed at the end of the description.

I'm not very good when it comes to using strings. I tried the following in the 'On Format' event of the 'Detail' section of my report without success:

Dim strDescription As String, strShortDesc As String

strDescription = Me.txtProduct
strShortDesc = Mid(strDescription,1, Instr(strDescription, "(")-1)
Me.txtProduct = strShortDesc

(Me.txtProduct) is the field on my report that displays the description.
I get an error that says:
'Run-time error '-214735267 (80020009)
You can't assign a value to this object.

I can't see where i'm going wrong, please help!
 
Create a textbox on your report set the control source to:

[tt]=Mid(Product,1,Instr(Product,"(")-1)[/tt]

Where Product is the name of the field that holds the description.
 
THANK YOU THANK YOU!!!!

You are a legend! That worked beautifully!
 
I have one other question if i may!

If i have a product description that doesn't have brackets after it, i get an "Error". How do i overcome this?
 
How about:

[tt]=IIf(Instr(Product,"(")>0,Mid(Product,1,Instr(Product,"(")-1),Product)[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top