Convert Field from 10 positions to 4

M

Mary M

If you have a text field with a length of 10 ex. 1234567890. How can you
write a qurey that will update a field with a length of 4 with the
3rd,4th,5th and 6th position so that the new field will be 3456?

Many thanks in advance.
 
B

Brendan Reynolds

UPDATE tblTest SET tblTest.TargetField = Mid$([SourceField],3,4);

Note though, that if both values are required (the original 10 characters
plus the calculated 4 characters) in most situations it will be better not
to store the calculated value, but to calculated it as required in a select
query (so that it is always based on up-to-date source data) ...

SELECT tblTest.SourceField, Mid$([SourceField],3,4) AS FourChars
FROM tblTest;
 

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