read each line of a text box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I read each line of a multiline textbox seperately?
I want my users to be able to enter a list of account numbers and then type
in one comment and have it create a record in a comment table for each
account number.

Thank you
 
Chris said:
How can I read each line of a multiline textbox seperately?
I want my users to be able to enter a list of account numbers and
then type in one comment and have it create a record in a comment
table for each account number.

Thank you

You could split the text box's contents into an array using the Split
function, if you're using Access 2000 or later:

Dim astrLines() As String
Dim strLine As String
Dim I As Integer

astrLines = Split(Me!MyTextBox & vbNullString, vbCrLf)

For I = LBound(astrLines) to UBound(astrLines)
strLine = astrLines(I)
' ... do something with strLine ...
Next I
 
"Chris" wrote
How can I read each line of a
multiline textbox seperately?

If the lines were created by Enter or Ctrl-Enter (as specified in Enter Key
Behavior) they will be separated by a Carriage Return and Line Feed, for
which you can search by using the builtin constant vbCrLf. If you are just
taliing about word wrap, you can't determine where a "line" ends.
I want my users to be able to enter a
list of account numbers and then type
in one comment and have it create a
record in a comment table for each
account number.

Consider using a Subform with a Continuous Forms View of the CommentTable,
instead... with Access having such good facilities for entering separate
Records, it just isn't efficient to use a single Text Box and have to parse
the Text, then write the Records from VBA Code.

Larry Linson
Microsoft Access MVP
 
Back
Top