MS Access Import only specific row from a text file

learning vba

New Member
Joined
Nov 20, 2016
Messages
8
Hi all,

I need some help in importing a text file into ms access, this file is fixed lenght however there are 3 length types

first column is "Frequency" starts from 1 length 2
based on this field the length of other columns are determined
eg:
Case1:
if "Frequency" field is 01 then the
currency starts from 6 and length is 3
rate starts from 12 and length is 8

Case2:
if "Frequency" field is 02 then the
currency starts from 15 and length is 3
rate starts from 28 and length is 8

Case3:
if "Frequency" field is 03 then the
currency starts from 7 and length is 3
rate starts from 35 and length is 8

If i use a saved specs for case 1, it reads and loads the entire file and messes up with the colums

is there a Ms Access vba code that i can use to read the text file and import only rows where Frequency" field= 01 or 02

i tried usinig the .ini file but couldn't get through.

the txt files are huge hence cannot i have to import only specific rows

Thank you in advance
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Here is another way to go about it that does not require any VBA.

Import all the records as into a Temporary Table of two fields using a Fixed Width Import
- First field: Frequency (two characters wide)
- Second field: Everything else (dump into one long string/memo field)

Then, you can create two Append Queries to write your data to the table
So create one that only returns data where the first field is "01", and you can use string functions to pull what you need from the second field, and write to your final destination table.
Your second one would follow the same process, but be for records where your first field is "02".
 
Upvote 0

Forum statistics

Threads
1,215,482
Messages
6,125,061
Members
449,206
Latest member
Healthydogs

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top