inserting each line of text as a record

swmorin

Registered User.
Local time
Yesterday, 19:43
Joined
Jan 10, 2012
Messages
66
I have a form on db that is a multiline text box. I want to insert the information in that field into another table.

How do I make access insert each line of text in the text field as a new record.
 
Why have multiple lines in the first place? Can you explain the reasoning?
 
I'm not soure, Check this:
Code:
Sub a()
    Dim strArr() As String
    Dim var As Variant
    strArr = Split(MyTextBox, Chr(13))  ' Chr(13)-> newLine Char.
    For Each var In strArr
        'Insert var
    Next
End Sub
 
Sure.

I am making a db for different courses in a school. Each chapter of each course has 2 guaranteed requirements to teach. However each chapter could have several other requirements. I want to put a multi line field and each line they enter would be a requirement.

I.E.
Mandatory Requirement 1
Mandatory Requirement 2
Optional Requirement 1
Optional Requirement 2

would insert four records into courserequirements table.
 
Marlan,
Thanks you got me on the right track. The only thing I had to change was after each text there is chr(13) and chr(10). The code looked like this.

Code:
Dim txtstr() As String
Dim txtvar As Variant
txtstr = Split(Me.Text0, Chr(13) & Chr(10))
For Each txtvar In txtstr
  Insert Query
Next
End Sub
 
Glad I could help.

try VbCrLf instead of Chr(13) & Chr(10)
 
vbCrLf is not equivalent to Chr(13) & Chr(10). It's equivalent to only Chr(13)

Anyway, I still don't see the point of doing this. Why don't you use a form in datasheet view or a continuous form?
 
vbainet,
ALl I can say is this works best for what I am trying to do i this case.
 
Just because it works doesn't mean it's how the operation should be performed.

I rest my case since you're happy with the solution. ;)
 

Users who are viewing this thread

Back
Top Bottom