Hi Steve,
Your "why" question is entirely valid. I'll try to explain the reasoning.
Why 1
------
Some existing data formats are inherently column-organised. Imagine
importing the headers from a large mailbox. Each mail header looks like:-
Date: xxxxxxxxxx
Subject: xxxxxxxxxxx
To: xxxxxxxxxx
From: xxxxxxx
but your required "MyMails" table would look like:-
ID Date Subject To
From Body......
-- ------- ---------- --------
-------- ----------
01 01/01/2006 Access Question xxxxxxx xxxxxxxx
........
02 01/01/2006 Another Question xxxxxxx xxxxxxxx
........
Why 2
------
When designing a form-like data collection method in either a spreadsheet
or an HTML mail template(yes I know ideally this would BE an online form, but
sometimes this is not an option) there is often some combination of
information that applies to the whole sheet, then repeated tabular
information. I.e:-
Name: xxxxxxx
Submission Date: xxxxxxxx
Reason for Claim: xxxxxxxxxx
Claim Items
No Description Date
--- ----------- -----
01 Description 1 01/01/2006
02 Description 2 01/02/2006
The header (and maybe footer) needs to be pulled out and transposed as
above, then the body imported into a separate table in a one-many
relationship. I know about transposing in Excel, but I'd like to minimise the
number of external conversion trips here, HTML->Excel->Access looks
unnecessarily complicated.
If this is completely invalid (i.e. there's a far better way of doing it)
please let me know, but it seems to be a reasonable approach.
BTW- I had not grasped the clear distinction between Macros and VBA. The
latest Access docs seem to downplay Macros and recommend VBA for new work,
the action builder offers both, and the DoCmd object blurs the boundaries.
Also I didn't see an "Access.VBA" forum, although I need to re-check this. I
read "Access.Macros" as meaning "Access.Scripting_and _Coding".
Regards: Colin
"Steve Schapel" wrote:
> Colin,
>
> Leaving aside for the moment the question of *why* you want to do this
> (i.e. take normailised data and transfer it into an Access table (where
> Access thrives on normalisation) in a denormalised state!)... Can i
> just make sure I understand that you want the table to end up with only
> one record, with the field name corresponding with the value in one of
> the original columns? Well, you asked the question about "VBA loops",
> and yes, this would be an option. But the focus of this newsgroup is
> macros, which have nothing to do with VBA, and you could also do it with
> macros using a series of OpenQuery actions to run a series of Update
> queries. The other approach is to move the data into Excel, where
> transposing is much more simply achieved, and then import to your Access
> table after that. But the 'why' is still plaguing me. :-)
>
> --
> Steve Schapel, Microsoft Access MVP
>
>
> colin_e wrote:
> > I know transposing data is a commonly-asked question in the forums, but
> > although I have read a lot of the answers I have not found exactly the
> > solution I need.
> >
> > I am importing data from 2-column HTML Table , in the form:
> >
> > Item Name 1: Value 1
> > Item Name 2: Value 2
> > .
> > .
> >
> > After import I need to transpose this and add it to a table in the form:
> >
> > Key Item Name 1 Item Name 2...
> > --- ----------- -- -------------
> > Key 1 Value 1 value 2
> >
> >
> > I have seen reference to using crosstab queries, but Access refuses to
> > define and run a crosstab query with only two source columns, and anyway
> > crosstabs require a numerical column to be able to aggregate as the value of
> > the crosstab.
> >
> > Do I have no choice but to write VBA loops to grind through all the data
> > mechanically, or is there a neat way of achieving this?
> >
> > Regards: Colin
>
|