tags:

views:

55

answers:

1

Have a program in MS-Access, using VBA. I need to come up with an If statement to pull data from a text file. The data is a list of procedures and prices. I have to pull the prices from the text file to show in a report how much each procedure costs.

ID     PID                    M1      M2     M3    Total      
1     11120390(procedure)    
2       180(price)           360     180     540     1080(total Price)
3                             2       1       3       6(Units sold)
4       
5       200(Price)           200     600     800     1600(total price)
6                             1       3       4       8(Units Sold)
7     11120390(procedure)

The table in the text file is setup like this and I need to Pull the procedure number and the price of each procedure from the text file.

A: 

This is a general answer to a vaguely-presented question. You typically have to go through these steps:

  1. Make a connection to the file
  2. Open the file
  3. Parse the file (as Simon was saying): go through it as a series of strings, find an orientation point, get to the relevant parts
  4. Import the relevant parts, perhaps in a holding table
  5. Present the data in typical Access fashion (query, report)

And if the file isn't well structured or correctly generated, you'll need extra parsing code and perhaps error handling to deal with aberrations.

Smandoli