Help with Code

  • Thread starter Thread starter DeWayne
  • Start date Start date
D

DeWayne

I'm trying to read a feild from a record that is xxxxxxx-
x*xxxxxxx-x one time than xxxx*xxxx the next time. What
I'm trying to do is read the feild up to * then write it
to anther feild in the record. Can some please help me

thank you
dewayne
 
This sounds like you should really have two fields - one for the bit before
the * and one for the bit after...

Also, storing a calcuated result in a table is usually considered a BAD
IDEA.

However, if you insist that this is how it must be done then you will need
to use the string functions InStr and Left in an expression such as this:

Left(strString, InStr(1, strString, "*", vbTextCompare) - 1)

Where strString is a string consisting of your original field value.
 
I'm not sure you understand what my problem is. the come
to me this way some times the * is not in the data and
some times it's at the 5th place and some times it's 9th
and so on. I just want to pull the data out of this
feild up to the * and if there is not * all the data and
place it in a new feild.

I hope this help you understand what I'm doing.

thank you
dewayne
 
Use an UPDATE query and string functions.

UPDATE TableName as T
SET FieldA =
TRIM(LEFT(FieldB & " *",Instr(FieldB,"*")-1))
 
OK, but the formula that I gave you - virtually the same as the one from
John Spencer - should do what you need.
 
Back
Top