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

importing addresses

Status
Not open for further replies.

raybas

Technical User
Jul 19, 2001
9
US
I have scanned a maling list that is to be used as mailing labels and I have converted the images of these lables to the text. I want to be able to create a table with these addresses. I am not sure how I can import these or create a table because they are in a lable format so the address is underneath the name and etc. I would appreciate any help in creating something or using a tool to move all the info automatically into a table format. Thanks.
 
They are in a text file, or I can even paste them into an excel file. For example in an excel file the first column looks like this :

Name
Address
City, St Zip
Name
Address
City, ST Zip

The text file resembles the layout as well.
 
Then what I suggest is a little routine to read the text file and place the data into an address table.

I am assuming that you are just adding new records so I would read the text file and create address records. 1 address record for every three text records. If you would like some help with this just email me a text file with a dozen or so labels in it. I will look at it tonight and quickly write you up an import.

jwdconsulting@shaw.ca
 
What I would do, in all honesty, is use the following code - I've had some experience with Text File Reading:

'Initialization
Dim Dbs As Database
Dim Rst As Recordset
Dim LineCtr As Integer
Dim Len As Integer
Dim City as String
Dim FileNm
Set Dbs = CurrentDb
Set Rst = Dbs.OpenRecordset("NameOfAddressTable", dbOpenDynaset)

'Get filename from user
FileNm = InputBox("Input File Name without .txt", "")
If FileNm = "" Then
msgbox "Process cancelled!!!", vbCritical, ""
Exit Function
End If
If Len(Dir("c:\Progra~1\Sent\" & FileNm & ".mbx")) = 0 Then
msgbox "Filename is not found!!!", vbCritical, " "
Exit Function
End If

'Importing text file - Note, directory and filenames can be changed to protect the innocent =)
Open "C:\Temp\" & FileNm & ".txt" For Input As #1
LineCtr = 1
Do While Not EOF(1)
Line Input #1, LineData
Select Case LineCtr
Case 1 ' Name
Rst.AddNew
Rst!NameField = LineData
Case 2 ' Address
Rst!AddressField = LineData
Case 3 ' City, ST Zip+4
City = ""
Len = 1
Do While Mid(LineData,Len,1) <> &quot;,&quot;
City = City & Mid(LineData,Len,1)
Len = Len + 1
Loop
Rst!CityField = City
Rst!StateField = Mid(LineData,Len+3,2)
'Assuming that the Zip has one space between State and Zip and it's a Zip+4
Rst!ZipField = Mid(LineData,Len+6,10)
Rst.Update
LineCtr = 1
End Select
Loop
Close #1
Rst.Close

This is quick coding - I'm sure someone can think of ways to make this more efficient or whathaveyou, but I did this on the fly and modified it a little bit for your needs - I did NOT debug this. You just need to copy and paste this into your function and debug it from there. It should work.

HTH
Roy
aka BanditWk
Las Vegas, NV
roy@cccamerica.org
RLMBandit@aol.com (private)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top