Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Split a text string into two fields

Status
Not open for further replies.

tongaman

MIS
Jan 6, 2004
18
AU
Hi.

I would like to get some help to split a text field into two separate fields

I have a table called CUSTOMERS with a field text field called ACCOUNT_NO

The ACCOUNT_NO field is 9 charatcers long
I want to be able to write a query to split the current values in the ACCOUN_NO fields into two fields PREFIX and BASENUM.

Please refer to example below:
***Current State ****
ACCOUN_NO
123456789
***Desired Result ******
PREFIX BASENUM
123 456789

I wrote the query code below but received the following error message:
"Compile error. in query expression 'Left(ACCOUNT_NO],3)':


SELECT Customer.ACCOUNT_NO, Left([ACCOUNT_NO],3) AS Prefix, Right([ACCOUNT_NO],Len([ACCOUNT_NO])-3) AS BaseNum
FROM Customer;


Any help would be greatly appreciated.












 
Apologies for the typing error. The field should be ACCOUNT_NO and not ACCOUN_NO.

Cheers...
 
If you get an error when using Left(), it usually suggests a references issue. Check Doug Steele's page
Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top