PC Review


Reply
Thread Tools Rate Thread

How do i do this?

 
 
Emma Hope
Guest
Posts: n/a
 
      11th Mar 2010
I have a tab delimited text report sent to that looks something like this:

Trans SupplierA
A01 Data Data Data Data
A01 Data Data Data Data
A01 Data Data Data Data
A01 Data Data Data Data
Trans SupplierB
A01 Data Data Data Data
A01 Data Data Data Data
Trans SupplierC
A01 Data Data Data Data
A01 Data Data Data Data
A01 Data Data Data Data

and what i need is something like this in my final table

SupplierA A01 Data Data Data Data
SupplierA A01 Data Data Data Data
SupplierA A01 Data Data Data Data
SupplierA A01 Data Data Data Data
SupplierB A01 Data Data Data Data
SupplierB A01 Data Data Data Data
SupplierC A01 Data Data Data Data
SupplierC A01 Data Data Data Data
SupplierC A01 Data Data Data Data

i.e. the 'data' has a 'header' row and i want the name from the header row
to be against each 'data' row.

The number of rows of data for each supplier can vary significantly. The
'header' row always has Trans in the first field and the 'data' rows always
have A01 in the first field.

Can anyone advise how i might achieve this?

Thanks
Emma

 
Reply With Quote
 
 
 
 
Roger Carlson
Guest
Posts: n/a
 
      11th Mar 2010
On my website (www.rogersaccesslibrary.com), is a small Access database
sample called "ImportLineInput.mdb" which illustrates in general how to do
this. The specifics will have to be adapted a tab delimited file. You can
download it for free here:
http://www.rogersaccesslibrary.com/f...ts.asp?TID=340.


--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/...UBED1=ACCESS-L




"Emma Hope" <(E-Mail Removed)> wrote in message
news:49F0EC57-7E0A-4E39-923F-(E-Mail Removed)...
>I have a tab delimited text report sent to that looks something like this:
>
> Trans SupplierA
> A01 Data Data Data Data
> A01 Data Data Data Data
> A01 Data Data Data Data
> A01 Data Data Data Data
> Trans SupplierB
> A01 Data Data Data Data
> A01 Data Data Data Data
> Trans SupplierC
> A01 Data Data Data Data
> A01 Data Data Data Data
> A01 Data Data Data Data
>
> and what i need is something like this in my final table
>
> SupplierA A01 Data Data Data Data
> SupplierA A01 Data Data Data Data
> SupplierA A01 Data Data Data Data
> SupplierA A01 Data Data Data Data
> SupplierB A01 Data Data Data Data
> SupplierB A01 Data Data Data Data
> SupplierC A01 Data Data Data Data
> SupplierC A01 Data Data Data Data
> SupplierC A01 Data Data Data Data
>
> i.e. the 'data' has a 'header' row and i want the name from the header row
> to be against each 'data' row.
>
> The number of rows of data for each supplier can vary significantly. The
> 'header' row always has Trans in the first field and the 'data' rows
> always
> have A01 in the first field.
>
> Can anyone advise how i might achieve this?
>
> Thanks
> Emma
>



 
Reply With Quote
 
Emma Hope
Guest
Posts: n/a
 
      16th Mar 2010

Roger,

Thanks for taking the time to respond but your solution seems to bear no
relation to my problem.

Can anyone else think of a solution to this problem please.

Thanks
Emma
 
Reply With Quote
 
Roger Carlson
Guest
Posts: n/a
 
      17th Mar 2010
It doesn't? How odd because I was able to modify it as follows:

'--------------------------
Function ImportTable()
Dim dbs As Database, rst As Recordset
Dim Directory As String
Dim MyString As String
Dim Supplier As String

DoCmd.SetWarnings False
DoCmd.RunSQL "Delete * from MyTable"
DoCmd.SetWarnings True

Set dbs = CurrentDb
Directory = (Mid(dbs.Name, 1, Len(dbs.Name) - Len(Dir(dbs.Name))))

Open Directory & "\TextReport.txt" For Input As #1

' Create a dynaset-type Recordset object based on table.
Set rst = dbs.OpenRecordset("MyTable")

Do While Not EOF(1)
Line Input #1, MyString

If Left(MyString, 5) = "Trans" Then
Supplier = Mid(MyString, InStr(MyString, Chr(9)) + 1)
Else
'Add a new Record
rst.AddNew
rst!Field1 = Supplier

rst!Field2 = Left(MyString, InStr(MyString, Chr(9)) - 1)
MyString = Mid(MyString, InStr(MyString, Chr(9)) + 1)
rst!DataField3 = Left(MyString, InStr(MyString, Chr(9)) - 1)
MyString = Mid(MyString, InStr(MyString, Chr(9)) + 1)
rst!DataField4 = Left(MyString, InStr(MyString, Chr(9)) - 1)
MyString = Mid(MyString, InStr(MyString, Chr(9)) + 1)
rst!DataField5 = Left(MyString, InStr(MyString, Chr(9)) - 1)
MyString = Mid(MyString, InStr(MyString, Chr(9)) + 1)
rst!DataField6 = MyString
rst.Update
End If
Loop
' Close text file.

MsgBox "Done!"

Close #1
rst.Close
Set dbs = Nothing

End Function
'--------------------------

Which seems to import the text file nicely.

--
--Roger Carlson
MS Access MVP
www.rogersaccesslibrary.com
http://rogersaccessblog.blogspot.com/


"Emma Hope" <(E-Mail Removed)> wrote in message
news:C9CC0C0E-7264-41CB-AC5D-(E-Mail Removed)...
>
> Roger,
>
> Thanks for taking the time to respond but your solution seems to bear no
> relation to my problem.
>
> Can anyone else think of a solution to this problem please.
>
> Thanks
> Emma



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:45 PM.