******** NOTE! ************
The WrkOdrG.TXT file MUST BE placed in a directory named: C:\OBTAIN
(You may alternatively edit the macro MMSB.IGbo to reset the import
function to locate the file elsewhere.)
It is large, therefore you may wish to regard it's 2.5M size.


The Idea:

The object of this project was to extract pertinent information from
an extremely large main-frame flat-file and place it into tables that were
more manageable by Access.  The data had be retrieved weekly and stored in
weekly records to allow for year-to-date calculations and weekly, monthly,
quarterly, and annual reporting. It also had to provide means of looking
back at any particular week for comparison.


The Data:

In order to obtain specific bits of data from a rather large main-frame,
the data file had to first be exported from the main-frame as a fixed
width text file. Then imported into Access through the Fixed-Width Text
import feature. After setting the fixed-width parameters, the file was
then imported into the required fields of tables that would be used to
temporarily retain the data. (The client elected NOT to opt for ODBC.)


The Source Table:

Once the data was imported into a table, an update querie was run to set
the date values to Access legible dates. (the OS-400 delivered the dates
as separate day/month/year field-text in reverse order and with out the
'/'s <slashes>.)


The Main Storage Table:

A table was designed with 'year' and 'week' fields set as primary keys.
The remaining fields will contain the data as disclosed by the following
query.


The Query:

Now the neat stuff starts.  To obtain values of counts and/or sums of the
data just acquired, only one end-value at a time could be searched for,
due to the amount of criteria sets required to obtain it. Certain values
in the search criteria were client determined and others cyclically fixed. 
Those cyclical values were hand-placed into a new table and a form was based
on that table.

Then, instead of placing a literal value for criteria in QBE grid, the
[Forms]![Formname]![Control] scenario was employed. In otherwords, the
criteria for a particular field in the QBE grid was set to look at a
value contained in an open form rather than stating the value in the grid.

Two queries were used because of the variance client determined criteria.


The Code Form:

A form was created and based a table that contained the cyclical info we
wanted in the QBE grid. The first form field contains the code we're actually
looking for in the imported table and the other form field contains the name
of the table field we want to place the data into.


The Code Form's Source Table:

The table the above form is based on has just two fields, 'Srvc' and 'SrvCode'.
These fields are hand entered just once, as the 'Srvc' and 'SrvCode' names won't
change.


The Elements:

Now we had a source table, a weekly storage table, a query for finding the
data we wanted, and a form to direct the query.  Next we needed some way
of managing the timing of:
	1) Opening the Weekly Storage Table
	2) Opening the Form (and ensuring that it opened on the first record)
	3) Opening the Query
	4) Copying the value of the query results into the first field of
	   the table
	5) Increment the record of the form
	6) Requery the query (looking to the new value in the form)
	7) Copying the value of the query results into the 2nd field of
	   the table
	8) And repeating this process until the record of the Weekly
	   Storage Table is complete


The Macro:

To manage the process of condensing and obtaining the information from the
big table to the smaller table, a macro was in order. Instead of trying to
explain it here, examine the macro object 'Obtain' in the MSAccess
database 'Obtainer' (Obtainer.MDB).


The Zip File:

Contains the following files...
	1) Obtain.MDB (the database)
	2) Obtain.TXT (this file)
	3) WrkOrdrG.TXT.TXT (a sample of the client's AS-400 download)


The MDB Contains the following objects:

Tables:		GWCTbl - 	Weekly storage for 'Obtained' data.
		SrvACodeTbl - 	Table sourcing the WOCF form, which provides
				the pointers for the 'GACQ' and 'GPCQ' queries.
		WeekTbl - 	Table containg week-date info. (The entire database
				pivots around the dates and times in this table.)
		WrkOrdrG - 	A table that temporarily holds the imported text file.
				(When completed, this table is normally emptied.)

Queries:	GACQ -		The Query containing the criteria for part of what is
				needed on a weekly basis from the WrkOrdrG table.
		GPCQ -		The Query containing the criteria for the remainder of
				what is needed on a weekly basis from the WrkOrdrG table.

		!WrkOrdrGTblUpdtQ - 	The query that updates the WrkOrdrG table to set
					it's dates to proper MSAccess date format.

Forms:		MainMenu -	Main Menu
		WOCF -		The form by which the GACQ and GPCQ queries receive their
				pointers.

Macros:		Autoexec -	Opens the Main Menu
		MMSB -		the macro that handles it all

******** NOTE! ************
The WrkOdrG.TXT file MUST BE placed in a directory named: C:\OBTAIN
(You may alternatively edit the macro MMSB.IGbo to reset the import
function to locate the file elsewhere.)
It is large, therefore you may wish to regard it's 2.5M size.



The Author:

Having avoided databases like the plague for most of his computer life,
Mark Davis has been designing in Microsoft Access since December of '92.
(So it is likely that this entire dialog and process are over-lengthy and
redundant; it is however also possible that someone may benefit from this
approach. It is also likely that Access Basic would have provided a more
eloquent solution, however Mark does not know AB yet and therefore develops
entirely without it. For now.)

Many contributors here on the Compuserve MSAccess Forum have provided many
solutions and helps that have tremendously aided me in development. This is
a small way of saying thanks.

And: There is no warranty of any kind provided with this. Nor is it supported
     by Microsoft.

Mark Davis
CServe: 75740,770
