I'm almost done

J

James Warpup

Sry to bother you guys again, I know you're busy.

I want to match a word to a string and then change part of the word. lets
take "parler" (to speak).

all i want to know is how can i set a variable to equal any number of
charicters before a given value. For example if a control contains the
value "parler" I need to set a variable = "parl" if it's "aider" i need
the same variable to = "aid". if it's intercéder the variable shold =
"intercéd"
 
B

BruceM

You could use an expression something like this:

Left([SomeField],InStr([SomeField],"er")-1)

If the word may not have "er" in it you could do:

IIf(InStr([SomeField],"mu")=0,[SomeField],Left([SomeField],InStr([SomeField],"mu")-1))

Maybe ti would be something like:

Dim strWord as String

strWord =
IIf(InStr([SomeField],"mu")=0,[SomeField],Left([SomeField],InStr([SomeField],"mu")-1))
 
L

Linq Adams via AccessMonster.com

I'm not at all clear what you mean by this

"how can i set a variable to equal any number of characters before a given
value"

especially the "before a given value" part!

You examples indicate that you want to truncate your source string by
returning all but the last two characters. This bit of code will do that:

NewString = Left(Me.SourceString, Len(SourceString) - 2)

"parler" will return "parl"
"aider" will return "aid"
"intercéder" will return "intercéd"

If you need more help I think you'll need to give a little better explanation
of your exact needs.
 
T

Tom Lake

James Warpup said:
Sry to bother you guys again, I know you're busy.

I want to match a word to a string and then change part of the word. lets take
"parler" (to speak).

all i want to know is how can i set a variable to equal any number of charicters
before a given value. For example if a control contains the value "parler" I need
to set a variable = "parl" if it's "aider" i need
the same variable to = "aid". if it's intercéder the variable shold = "intercéd"

A combination of Left and InStrRev functions will get you characters from the
left side of the string:

Left("parler", InStrRev("parler", "er") - 1) = "parl"
Left("aider", InStrRev("aider", "er") - 1) = "aid"
Left("intercéder", InStrRev("intercéder", "er") - 1) = "intercéd"

Tom Lake

Aides-toi, le Ciel t'aidera.
 

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

Top