S
Steven M. Britton
The below code doesn't currently work, looking for any
ideas - I have also included at the bottom the original
string from this newgroup. I have made a slight change
from my original question. Originally I wanted to take
the data out of a link txt file and split the Address
field so I could then add it to a perment table. Now all
I need to do is just split the text with in its current
table. Thanks again.
Option Compare Database
Private Sub btnUpdateDazzleRecords_Click()
On Error GoTo Err_btnUpdateDazzleRecords_Click
Dim strAddrParts(1) As String
Set db = CurrentDb
Set rs = db.OpenRecordset("tblDazzlePassThrough",
dbOpenDynaset)
rs.MoveFirst
Do While Not rs.EOF
strAddrParts = Split(rs!Address, ",")
' Read each element in the array
rs.AddNew
rs!ContactName = strAddrParts(0)
rs!CustReference = strAddrParts(1)
rs.Update
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Exit_btnUpdateDazzleRecords_Click:
Exit Sub
Err_btnUpdateDazzleRecords_Click:
MsgBox Err.Description
Resume Exit_btnUpdateDazzleRecords_Click
End Sub
-----------------------------------------------------------
Original Post and Answer-----------------------------------
. Reply (E-mail) Forward (E-mail)
Subject: Re: MVP Needed - Parse a string of text from a
linked .txt file
From: "Cheryl Fischer" <[email protected]>
Sent: 4/27/2004 5:02:10 PM
Steven,
You will need to use some VBA for this, I believe, with
the Split() function
delimiting the string on the comma. Perhaps something
like the following
(untested) code:
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strAddrParts() As String
Set db = CurrentDb
Set rs = db.OpenRecordset("tblAddress", dbOpenDynaset)
rs.MoveFirst
Do While Not rs.EOF
ReDim strAddrParts(0)
strAddrParts = Split(rs!Addr, ",")
' Read each element in the array
rs.AddNew
rs!AddresseeName= strAddrParts(0)
rs!Company = strAddrParts(1)
<continue with code to add address fields>
rs.Update
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
hth,
--
Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX
message
ideas - I have also included at the bottom the original
string from this newgroup. I have made a slight change
from my original question. Originally I wanted to take
the data out of a link txt file and split the Address
field so I could then add it to a perment table. Now all
I need to do is just split the text with in its current
table. Thanks again.
Option Compare Database
Private Sub btnUpdateDazzleRecords_Click()
On Error GoTo Err_btnUpdateDazzleRecords_Click
Dim strAddrParts(1) As String
Set db = CurrentDb
Set rs = db.OpenRecordset("tblDazzlePassThrough",
dbOpenDynaset)
rs.MoveFirst
Do While Not rs.EOF
strAddrParts = Split(rs!Address, ",")
' Read each element in the array
rs.AddNew
rs!ContactName = strAddrParts(0)
rs!CustReference = strAddrParts(1)
rs.Update
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Exit_btnUpdateDazzleRecords_Click:
Exit Sub
Err_btnUpdateDazzleRecords_Click:
MsgBox Err.Description
Resume Exit_btnUpdateDazzleRecords_Click
End Sub
-----------------------------------------------------------
Original Post and Answer-----------------------------------
. Reply (E-mail) Forward (E-mail)
Subject: Re: MVP Needed - Parse a string of text from a
linked .txt file
From: "Cheryl Fischer" <[email protected]>
Sent: 4/27/2004 5:02:10 PM
Steven,
You will need to use some VBA for this, I believe, with
the Split() function
delimiting the string on the comma. Perhaps something
like the following
(untested) code:
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strAddrParts() As String
Set db = CurrentDb
Set rs = db.OpenRecordset("tblAddress", dbOpenDynaset)
rs.MoveFirst
Do While Not rs.EOF
ReDim strAddrParts(0)
strAddrParts = Split(rs!Addr, ",")
' Read each element in the array
rs.AddNew
rs!AddresseeName= strAddrParts(0)
rs!Company = strAddrParts(1)
<continue with code to add address fields>
rs.Update
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
hth,
--
Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX
message