Change values in the middle of a text field globally

K

Ken Smith

I have an application used to bill for water and sewer charges that imports
readings from a text file produced by a radio frequency meter reader.

My Meters table includes a text value used to interface to the radio reader.
I need to update positions 53 through 62 with another value.

In desperation I tried an update query using the expression
Mid([RadioIDval],53,10) = [NewValField]. All records were set to zero.

How can I update the value of just those positions????
 
W

Wayne Morgan

Use an Update Query to update the field RadioIDval to:

Replace([RadioIDval], Mid([RadioIDval], 53, 10), [NewValField], 53, 1)

The last 2 parameters will limit the replacement to the characters starting
at position 53 and only do one replacement. They aren't necessary if the
character string you're replacing only exists one time in the entire string.
Also, is [NewValField] another field in a table in the query? If not, where
does this value come from? If so, it should work. If it is from a second
table in the query (i.e. not the table you're updating the field in) then
the two tables will need to be linked on a common field so that the query
will know which row in the second table goes with which row in the table
you're updating.
 

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