Copy 1 Field To Multiple Fields

threeo2

Registered User.
Local time
Today, 04:13
Joined
Feb 11, 2003
Messages
31
I have a field [CustInfo] on a Customer Information form with control source to a memo field. It looks like this:

NAME
ADDRESS
CITY
STATE
ZIP

I want to be able to press a button that will copy the individual lines of this field to their respective fields on the form.

example:

.Name = Line1 ([CustInfo])
.Address = Line2 ([CustInfo])
.City = Line3 ([CustInfo])
.State = Line4 ([CustInfo])
.Zip = Line5 ([CustInfo])

Is there an easy way to do this?
 
Why would you store this data in a memo field? You should really change your table and store the data in separate fields.

To parse the memo field, you would need to write a code loop that made use of the Instr() function to find the separation character that identifies where one data part ends and the next starts. Search here for parsing for code examples.
 
Thanks Pat, We're getting rid of old customers in the db and at the same time trying to convert to seperate fileds for their info.
 
Figured out a way to do it from several other posts. Works pretty well.
Thanks to all.



Mystring = [CustInfo]
MyArray = Split(Mystring, Chr(13), -1, 1)

Me![Name] = MyArray(0)
Me![Address] = Mid(MyArray(1), 2)
Me![City] = Mid(MyArray(2), 2)
Me![State] = Mid(MyArray(3), 2)
Me![Zip] = Mid(MyArray(4), 2)
 

Users who are viewing this thread

Back
Top Bottom