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!

when searching a memo field how do i move to the next line

Status
Not open for further replies.

lewie

Technical User
Jan 17, 2003
94
US
I have a text field with name address city ect. I am extracting the pieces and building a new table with name, address, city state, zip fields. I loaded the first line in to fname and lname
what code to i use to start at the second line so i can read that. is it chr(13) and Chr(10) but how do i get them to execute????

Private Sub Command14_Click()
'Public Sub FindString(strWord As String)

Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim rst1 As DAO.Recordset
Dim i As Integer
Dim end1 As Integer
Dim begin1 As Integer
i = 1
Dim string1 As String

Set db = CurrentDb()

' Create recordset on tblcontact information
Set rst = db.OpenRecordset("Contact information", dbOpenDynaset)
Set rst1 = db.OpenRecordset("newcontact", dbOpenDynaset)

With rst

' string1 = rst.Fields("contact")
Do While Not .EOF 'loop through entire table
i = 1 '
string1 = rst.Fields("contact") 'string 1 is memo field
Do While Mid(string1, i, 1) <> " " 'search for first name
i = i + 1
Loop 'end loop
rst1.Edit ' edit table
rst1.Fields("fname") = Left(rst.Fields("contact"), i - 1) 'put the first name in db
rst1.Update 'update field
begin1 = i + 1 ' find the second name
Do While Mid(string1, i + 2, 1) <> Chr(13)
'If Mid(string1, i + 2, 1) = " " Then
' MsgBox "i need to enter a cr"
'Stop
'End If
i = i + 1
Loop
end1 = i '
rst1.Edit
rst1.Fields("lname") = Mid(rst.Fields("contact"), begin1, end1) 'put last name in box
'Forms!newcontact!lname = Mid(rst.Fields("contact"), begin1, end1)
rst1.Update 'write it
'should be on new line
Chr (13) & Chr(10)
Do While Mid(string1, i, 1) <> Chr(13) 'search for the address
i = i + 1
Loop 'end loop
rst1.Edit ' edit table
rst1.Fields("studio") = Left(rst.Fields("contact"), i - 1) 'put the first name in db
rst1.Update


rst1.MoveNext 'move to next record in new db
rst.MoveNext 'move to next record in old db

Loop 'process new record
.Close 'close rst
rst1.Close 'close rst1
End With 'end process of rst
End Sub
TIA
 
vbCrLf is the newer "replacement" for Chr(10) & chr(13).

When I'm looking for Line feeds, i use
iFound = InStr(rst!Contacts,vbCrLf)
If iFound > 0 Then 'will return 0, if line feed not found.
sNewLine = Mid(rst!Contacts,iFound + 1)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top