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!

Missing values from an imported .txt file to an access table

Status
Not open for further replies.

yambuta

Technical User
Jul 13, 2003
2
US
Help ! I am designing this simple database to retrieve some data. The source data is a .txt file that is imported. The data however is not consistent, for example:
item location name
------ --------- -----
r5 22110001 conn
33110001 conn
44110001 conn
r6 11111111 plug
r7 11223344 plug

the empty space between r5 and r6 means it is still "r5". How do I fill this space with the actual value of "r5" without compromising the rest of the data. The file has over 300,000 records, and this situation is repeated many times over within the table.
I am still very green when it comes to Access97. Please help. Thank you in advance.

 
You will probably need to import it as it is, then loop through in code to fill in the missing values. e.g.

'Open updateable recordset R
'Loop through data
While Not R.EOF
If R("item").Value = "" then 'If item blank
'Will need a R.Edit here if using DAO
R("item").Value = LastItem 'Copy last item
R.Update
Else
LastItem = R("item").Value 'Save current item value
EndIf
R.MoveNext
Wend

It's probably not going to be very quick, but unfortunately it needs to processed sequentially so we can't use a query.
 
Thank you Norris68 for your prompt response. Unfortunately, I have never had to deal with recordsets and how they work. I'll need a walk-through, step-by-step, on how to create this. Do I create it as a module, or do I write the code outside of the database as a batch file? Can you be of assistance?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top