actually, it more like this:
field 1 = name field 2 = account # field 3 = date = field 4 = amount
field 5 = name field 6 = account # field 6 = date = field 7 = amount
and so on and so on (10 rolls of like info in seperate fields)
It was my first attempt!
You can unravel this "spreadsheet" into - I'm guessing - two tables, using
what's called a "Normalizing Union Query". First create your properly
normalized tables: one for Accounts, with Account # as the primary key; and
one for transactions, with Account # as a foreign key (same datatype but *not*
the primary key. I presume the name goes with the account? Not sure what you
want to do if you have Account 341 linked in one place with Joe Doakes, and in
another place with Mary Smith!
That said: create two tables:
Accounts
AccountNo <don't use # in fieldnames>
LastName
FirstName
<other data about the account or customer>
Transactions
TransactionID <Autonumber Primary Key>
AccountNo <same datatype as Accounts.AccountNo>
TransDate <don't use Date as a fieldname, it's a reserved word>
Amount <currency datatype>
Then you'll need two UNION queries: you'll need to build these in the SQL
window, the query grid isn't capable of doing this. Using your fieldnames
above (you'll need to edit them):
SELECT yourtable.Field2 AS Account, Yourtable.Field1 AS LastName
FROM yourtable
WHERE yourtable.Field2 IS NOT NULL
UNION
SELECT yourtable.Field6 AS Account, Yourtable.Field5 AS LastName
FROM yourtable
WHERE yourtable.Field6 IS NOT NULL
UNION
SELECT yourtable.Field10 AS Account, Yourtable.Field9 AS LastName
FROM yourtable
WHERE yourtable.Field10 IS NOT NULL
UNION
SELECT yourtable.Field14 AS Account, Yourtable.Field13 AS LastName
FROM yourtable
WHERE yourtable.Field14 IS NOT NULL
<etc etc through all ten sets of name/account fields>
Save this as uniAllAccounts. It will automatically strip out duplicates
(though if you have 341... Mary Smith and 341... Joe Doakes they will both be
there).
Now do the same thing using
SELECT yourtable.Field2 AS Account, yourtable.Field3 AS TransDate,
yourtable.Field4 AS Amount
FROM yourtable
WHERE yourtable.Field4 IS NOT NULL
UNION ALL
SELECT yourtable.Field6 AS Account, yourtable.Field7 AS TransDate,
yourtable.Field8 AS Amount
FROM yourtable
WHERE yourtable.Field8 IS NOT NULL
UNION ALL
<etc for ten repeats>
The UNION ALL will include duplicates - assuming that you might have two
transactions for the same account on the same date for the same amount; if
that can never happen in real life, use UNION instead of UNION ALL. Save this
query as uniAllTransactions.
Finally, create an Append query appending uniAllAccounts to Accounts, and
uniAllTransactions to Transactions. Run them both.
You should now be able to create a form based on Accounts, with a subform
based on Transactions. Once you're comfortable that you have all the data,
delete your "spreadsheet" table and use the new form for data entry and
editing.
John W. Vinson [MVP]