string manipulation

  • Thread starter Thread starter Miranda
  • Start date Start date
M

Miranda

hi guys,

i'm working on a report. one field on the report in an emp's name. A name
may appear like:

Green, Jane
or
Green, Jane (LH)

i want to be able to check the last char's to see if there is (lh) or not.
if there is, i want to trim these char's and just show Green, Jane.

can anyone point me in the right direction

Thanks in advance,
miranda
 
This will return everything up to but excluding the first opening bracket,
if any:

(untested)

rtrim$ (left$ ([empname] & "(", instr ([empname] & "(", "(") - 1))

HTH,
TC
 
hi guys,

i'm working on a report. one field on the report in an emp's name. A name
may appear like:

Green, Jane
or
Green, Jane (LH)

i want to be able to check the last char's to see if there is (lh) or not.
if there is, i want to trim these char's and just show Green, Jane.

can anyone point me in the right direction

Thanks in advance,
miranda

In a query:
SELECT Mid([FieldName],1,InStr([FieldName],"(")-1) AS exp
FROM YourTable
WHERE (((YourTable.FieldName) Is Not Null) AND
((InStr([FieldName],"("))>0));

Directly as control source of an unbound control in your report:

=IIf(InStr([Fieldname],"(")
0,Mid([FieldName],1,InStr([FieldName],"(")-1),[FieldName])
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top