By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,477 Members | 1,602 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,477 IT Pros & Developers. It's quick & easy.

one text file in to two different table

P: 92
I have a bog problem in access
what i have to do is that
i have a text file that i have to insert it into access. but the problem is that there is two differnt type of data in my text file.
the one that have rpt:1 have differnt format of those who hast rpt:2. but they are all in one text file.
what i want to di is that i want to say that when ever rpt is equal 1 put in this table and whenever the rpt is 2 put in the other table.

i have to be able to read the text file and then send it into another table

i would appreciate any help.
thanks
Sep 14 '07 #1
Share this Question
Share on Google+
3 Replies


JConsulting
Expert 100+
P: 603
I have a bog problem in access
what i have to do is that
i have a text file that i have to insert it into access. but the problem is that there is two differnt type of data in my text file.
the one that have rpt:1 have differnt format of those who hast rpt:2. but they are all in one text file.
what i want to di is that i want to say that when ever rpt is equal 1 put in this table and whenever the rpt is 2 put in the other table.

i have to be able to read the text file and then send it into another table

i would appreciate any help.
thanks
can you post a small sample of the data...and how it looks in the file?

something like this may help out

Expand|Select|Wrap|Line Numbers
  1. Function importtxtfile(strFile As String) As Long
  2. Dim MyString As String
  3. Open strFile For Input As #1
  4. Do While Not EOF(1)
  5.     Line Input #1, MyString
  6.     'Here you can either parse your fields based on the delimiter
  7.     'or you can use the instr(mystring, "xxx") to identify what table
  8.     'then
  9.     'use an insert statement to put the line into the proper table
  10. Loop
  11. Close #1    ' Close file.
  12. End Function
  13.  
J
Sep 14 '07 #2

P: 92
i havent done that much
i just create two tables with the fields.
if the report tybe be 1 then have different field with rport type 2.
also i dont wantt o enter all the fields that is in text field.
and also in my text field in one line there is two field in other line there is 3 field.
i may just need one field in one line and i also want to escape some lines.
if i want to explain i have to same that cosider that theree is comment card that the customer has fill it.
what i need is to get those fields that i need and then again go the next entry. this is a very big text file

thanks alot
Sep 14 '07 #3

JConsulting
Expert 100+
P: 603
i havent done that much
i just create two tables with the fields.
if the report tybe be 1 then have different field with rport type 2.
also i dont wantt o enter all the fields that is in text field.
and also in my text field in one line there is two field in other line there is 3 field.
i may just need one field in one line and i also want to escape some lines.
if i want to explain i have to same that cosider that theree is comment card that the customer has fill it.
what i need is to get those fields that i need and then again go the next entry. this is a very big text file

thanks alot
There has to be rules when it comes to automating the import of data. Without those , I do not know how to help you. I understand that you don't need ALL data...but to exclude some, or choose some based on some logic...YOU have to define that that is. I'll monitor this question if you can come back with some definition of that that is.
J
Sep 15 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.