Splitting Strings?

I have a field in a table called CustNumber and it has a length of 15 characters. I also have a field called Route which is 5 characters and a field called Account that is 10 characters.

The Route is the first 5 characters of the CustNumber field and the Account is characters 6 and up of the CustNumber.

My question is there a command that allows you to slice a string into segments in which I can load the contents to the Route and Account from the CustNumber so that the user does not have to enter those fields manually?


if len(custNum)=15 then route = left(custNum,5) accountNum = right(custNum,10) else beep

On further review, since your variables are textfields, add .text to the end of each (working with the text properties).

Also consider either disabling the Route and Account fields or converting them to Labels, so the user knows they don’t need to be entered again.

What type of table/fields are you talking about?

The direct answer to your question is yes. As Andrew pointed out above, Left and Right will do the job, and there is also Mid to start at an arbitrary point and get an arbitrary length. Check the LR for all of these.

It’s important to note that Left, Right, and Mid will never generate an error no matter what params you feed them. You could say Left( "", 6 ) or Right( s, -10) and you will always get some string result.

Thanks for all the replies. Your assistance is appreciated.

Jym, they are text fields and the tables are part of a SQLite database that will eventually go to a cubeSQL database on the web.