Displaying only part of a field

Jon123

Registered User.
Local time
Today, 13:35
Joined
Aug 29, 2003
Messages
668
On a report I have a field that has a value that can be anywhere from 15 to 25 char. Can I set up the report field to only display the 1st 10 char. ?

jon
 
Last edited:
I put this line in the on open property of the report and it won't take it. Error "expected = "

Left ([Module],10)
 
Add the equal sign before the statement, like below:

=Left ([Module],10)
 
I'm still get an error "expected line number or end of statement"

Jon
 
The examples shown include an unwanted space, i.e.
= left (
versus
= left(

try this experiment from the debug (immediate) window:

myfield = "the quick brown fox jumped"
? left(myfield, 12)
the quick br
 
Does it make a difference if this a subform?

On the on open event of the subforn I typed this code

Left([Module], 10) this one errored expected ='s

so I put this coed


=Left([Module],10) this one errored for expected line number

in but cases the code turned red and would not compile.

Jon
 
Jon -

A little confused here. This started out as a report and it's now become a subform? In either case, the OnOpen option is probably not going to fly.

If you want to only display the first x characters of a field, then create a query and incorporate your criteria, e.g. mymodule = left([module], 10), and use that as your report / subform record source.

Bob
 
Sorry for the confusion my typo it is a sub report.

anyway I like the querry idea. Is there a way that I can add a field to the qry grid and have that field do an If statement rather then cutoff part of the field value?
Meaning something like this

= If [Module] = "Mainframe xxxxxx" Then [Module] = "Mainframe"

jon
 
Well which is it, do you want the first 10 characters whatever they might be or do you want only records where the field starts with "Mainframe"?

You kept putting the expression in an event property. You needed to put the expression in the ControlSource property of a control and prefix it with an equal sign.
=Left(SomeField, 10)

to put it in a query as Bob suggested, use an empty column and in the Field: field put:

Left10Name:Left(SomeField, 10)
 

Users who are viewing this thread

Back
Top Bottom