RE: Split an array field

Tech-Archive recommends: Speed Up your PC by fixing your registry



Never mind the last post, I got it to work. I guess I didn't put into the
module exactly like Access wanted me too. When I went back & did an insert
Function it worked correctly.

"Klatuu" wrote:

> Here is a function you can call from your query to split the data into months:
>
> Function SplitIt(ByVal lngNdx As Long, ByVal strSplit As String) As Long
> Dim varaSplit As Variant
>
> varaSplit = Split(strSplit, ",")
> SplitIt = varaSplit(lngNdx)
> End Function
>
> You would call it in your query by using expressions instead of fields in
> the query builder. For example purposes, we will call the field with the
> values in it HIST_VALS
>
> So, Jan: SplitIt(0, HIST_VALS) | Feb: SplitIt(1, HIST_VALS)
> and so on for all the months.
>
> This will split the data out into a query for your. That is the easy part.
> The fun part will be excluding the months you don't want. That you will
> have to do in the criteria row of the query, but you run into the problem as
> in your example, you can't exclude January because you have January in one of
> the years. I will leave that to you.
>
> "Bill Phillips" wrote:
>
> > The elements are comma delimited. My filed could have the following data:
> > 1,2,3,4,5,6,7,8,9,10,11,12
> >
> > Element 1 represents the qty sold of an item in January, Element 2 qty sold
> > in Feb etc. The year is specified in it own field. So for the last 5 years of
> > sales I would have 5 records, each record having 12 qty elements. I believe
> > the table was created this way to save space and increase response time by
> > limiting the number of records needed to query. The table is linked to my ERP
> > program which means no changes to the table design.
> >
> > My question is How to write the query? I'm not sure on how to specify the
> > elements I need.
> >
> > "Klatuu" wrote:
> >
> > > See what problems bad design can create? Twelve values stuffed into one
> > > field. Whomever designed that should be stuffed in a bag and thrown in a
> > > field.
> > > Enough soap box, let's solve the problem:
> > >
> > > So how are the 12 elements delimited, in other words, how do you pull out
> > > one value and know what it represents?
> > > All you need to do is create a query and break the individual fields out
> > > into the query. For each of the columns, instead of putting a field name in
> > > the query builder, use an expression that will give you the value you want.
> > >
> > > "Bill Phillips" wrote:
> > >
> > > > I have a linked table to Access that consolidates sales history into 12
> > > > entries within a single field. I would like to query this table based on a
> > > > date range - say July 2003 through September 2004. In order to do this I need
> > > > to sum the proper elements of the field. Is there a fairly simple way to
> > > > achieve this without creating new tables where the data is broken out into
> > > > individual columns? I am using Access 2K3.
.



Relevant Pages

  • RE: Multiply qty of filtered records
    ... If you should want to try doing this with a query (which is probably the more ... etc in the bottom part of the design view. ... I do know how to get this information in a Report, ... Dim rs As DAO.Recordset ...
    (microsoft.public.access.modulesdaovba)
  • Re: Query Design View is Slow to Open
    ... same query takes about 20 minutes to open in datasheet view. ... took only seconds to open in both design view and datasheet view. ... The troublesome queries are based entirely on local tables (i.e. no ... HOUSEHOLD_PersonalInfo opens slowly in design ...
    (comp.databases.ms-access)
  • Re: Is this join valid?
    ... > complex set of tables and queries, but I've boiled down the behavior ... you describe a problem with the Design View that really should not ... affect what happens when running a query from ASP. ... > the SQL view after creating the query in Design View. ...
    (microsoft.public.inetserver.asp.db)
  • Re: query to combine values if true
    ... What if you keep your data tables in a well-normalized form (to help Access ... you can give them a form and a way to query and they'd be ... i am open to suggestions of a better design. ...
    (microsoft.public.access.gettingstarted)
  • Re: query where end user puts in selection criteria
    ... I'd like for a user to be able to select specific competencies so ... am used to working in design view and building queries for myself but this is ... build their own query from a form. ... "Duane Hookom" wrote: ...
    (microsoft.public.access.gettingstarted)