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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can each part of a value in a field be extracted into an array?

Status
Not open for further replies.

Doraemon

IS-IT--Management
Sep 12, 2003
31
HK
I have a field named "approver", which is a textbox for storing names of approvers. Each name will be in a new line in the textbox by pressing "Enter" key.

I would like to ask is it possible to extract each name back by writing codes?

Follwoing is part of my codes:

Dim approver_array(10) As String
Dim approver_names As String
approver_names = Me![approver].Value

... Don't know how to write...

Thanks for you help!
 
Hi,

Of course it is possible - what you need to do is search the textbox for vb/crlf combination and get everything up to each one.
If using access 2002 you can use the Split function, if not I would get a copy of my Tek-tips database from the downloads page on
John
 
Sorry, I can't find the db u specified in the web. I am using access 2000.

Can anyone tell me specifically how to write codes to do that?

Thanks a lot!
 
The Split() function is available in Access2K as well. The syntax is
Code:
Dim strText() as String
strText = Split(txtField,[Separator],[Limit],VbCompareMethod])
where the optional separator character defaults to blank if you don't include it. I don't know what the Limit parameter does 'cause I haven't used it, but VbCompareMethod decides whether the search is case-sensitive if you search for a string of characters.

PeteJ
(Contract Code-monkey)

It's amazing how many ways there are to skin a cat
(apologies to the veggies)
 
Thanks for reminding me of the split() function!

I can store each substring by using the split() function now, as indicated as follows:

Dim approver_str() As String
approver_str = Split(Me.approver_name, vbCrLf, , vbDatabaseCompare)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top