PC Review


Reply
Thread Tools Rate Thread

Array help...not even sure what to ask!

 
 
Dale
Guest
Posts: n/a
 
      1st Jul 2005
I have a table that captures the occurence of an event by date and hour in a
24 hour period. Columns are named
[0100], [0200],[0300]....[2400].

I want to capture the sum of the events by days, evenings and nights where
"days" = ([0800]+[0900}...+[1500])
"evenings" = ([1700]+[1800]...+[2400])

I'm trying to create a function for each of "days", "evenings" etc,
I didn't want to have to declare each variable everytime I invoke the
function from a query, thinking an array is the way to go? I'm hopelessly
lost...can an array work with columns or only rows? How do I reference the
column I want in the array?

Function DaySum() As Double
Dim Days
Days = Array("[0800]", "[0900]"...."[1500]")
DaySum = Days(1) + Days(2)....+ Days(8)
End Function

If you're not already rolling on the floor laughing at this poor
attempt....thanks for any help or pointers.





 
Reply With Quote
 
 
 
 
Duane Hookom
Guest
Posts: n/a
 
      1st Jul 2005
Is there any chance that you could normalize your table structure? Having
times as column names isn't ideal for querying data.

--
Duane Hookom
MS Access MVP


"Dale" <(E-Mail Removed)> wrote in message
news:O7xgZ%(E-Mail Removed)...
>I have a table that captures the occurence of an event by date and hour in
>a 24 hour period. Columns are named
> [0100], [0200],[0300]....[2400].
>
> I want to capture the sum of the events by days, evenings and nights where
> "days" = ([0800]+[0900}...+[1500])
> "evenings" = ([1700]+[1800]...+[2400])
>
> I'm trying to create a function for each of "days", "evenings" etc,
> I didn't want to have to declare each variable everytime I invoke the
> function from a query, thinking an array is the way to go? I'm hopelessly
> lost...can an array work with columns or only rows? How do I reference
> the column I want in the array?
>
> Function DaySum() As Double
> Dim Days
> Days = Array("[0800]", "[0900]"...."[1500]")
> DaySum = Days(1) + Days(2)....+ Days(8)
> End Function
>
> If you're not already rolling on the floor laughing at this poor
> attempt....thanks for any help or pointers.
>
>
>
>
>



 
Reply With Quote
 
Dale
Guest
Posts: n/a
 
      1st Jul 2005
I knew you were going to say that!! Unfortunately this is the way the data
is rec'd as an extract from another source.
I take it that means an array will not work with the data in this format.


"Duane Hookom" <duanehookom@NO_SPAMhotmail.com> wrote in message
news:%(E-Mail Removed)...
> Is there any chance that you could normalize your table structure? Having
> times as column names isn't ideal for querying data.
>
> --
> Duane Hookom
> MS Access MVP
>
>
> "Dale" <(E-Mail Removed)> wrote in message
> news:O7xgZ%(E-Mail Removed)...
>>I have a table that captures the occurence of an event by date and hour in
>>a 24 hour period. Columns are named
>> [0100], [0200],[0300]....[2400].
>>
>> I want to capture the sum of the events by days, evenings and nights
>> where
>> "days" = ([0800]+[0900}...+[1500])
>> "evenings" = ([1700]+[1800]...+[2400])
>>
>> I'm trying to create a function for each of "days", "evenings" etc,
>> I didn't want to have to declare each variable everytime I invoke the
>> function from a query, thinking an array is the way to go? I'm
>> hopelessly lost...can an array work with columns or only rows? How do I
>> reference the column I want in the array?
>>
>> Function DaySum() As Double
>> Dim Days
>> Days = Array("[0800]", "[0900]"...."[1500]")
>> DaySum = Days(1) + Days(2)....+ Days(8)
>> End Function
>>
>> If you're not already rolling on the floor laughing at this poor
>> attempt....thanks for any help or pointers.
>>
>>
>>
>>
>>

>
>



 
Reply With Quote
 
PC Datasheet
Guest
Posts: n/a
 
      1st Jul 2005
Dale,

An array will not work. You need to do two things:
1. Create a new table that looks like:
TblEventOccurence
EventOccurenceID
OccurenceDate
OccurrenceTime
Then you need to append your existing data one column at a time into this
table. You will then be able to easily do the query you want.
2. Create an intermediary database between the source of your data and your
database. You can then import your data into this database in the form of
each hour in a separate field like you now have in your database. Then you
need to create an export routine in this database that exports the data one
column at a time into the new table in your database.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(E-Mail Removed)
www.pcdatasheet.com

"Dale" <(E-Mail Removed)> wrote in message
news:O7xgZ#(E-Mail Removed)...
> I have a table that captures the occurence of an event by date and hour in

a
> 24 hour period. Columns are named
> [0100], [0200],[0300]....[2400].
>
> I want to capture the sum of the events by days, evenings and nights where
> "days" = ([0800]+[0900}...+[1500])
> "evenings" = ([1700]+[1800]...+[2400])
>
> I'm trying to create a function for each of "days", "evenings" etc,
> I didn't want to have to declare each variable everytime I invoke the
> function from a query, thinking an array is the way to go? I'm hopelessly
> lost...can an array work with columns or only rows? How do I reference

the
> column I want in the array?
>
> Function DaySum() As Double
> Dim Days
> Days = Array("[0800]", "[0900]"...."[1500]")
> DaySum = Days(1) + Days(2)....+ Days(8)
> End Function
>
> If you're not already rolling on the floor laughing at this poor
> attempt....thanks for any help or pointers.
>
>
>
>
>



 
Reply With Quote
 
Duane Hookom
Guest
Posts: n/a
 
      2nd Jul 2005
I would normalize the data into tables. It shouldn't make any difference how
the other source is structured.

--
Duane Hookom
MS Access MVP


"Dale" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I knew you were going to say that!! Unfortunately this is the way the data
>is rec'd as an extract from another source.
> I take it that means an array will not work with the data in this format.
>
>
> "Duane Hookom" <duanehookom@NO_SPAMhotmail.com> wrote in message
> news:%(E-Mail Removed)...
>> Is there any chance that you could normalize your table structure? Having
>> times as column names isn't ideal for querying data.
>>
>> --
>> Duane Hookom
>> MS Access MVP
>>
>>
>> "Dale" <(E-Mail Removed)> wrote in message
>> news:O7xgZ%(E-Mail Removed)...
>>>I have a table that captures the occurence of an event by date and hour
>>>in a 24 hour period. Columns are named
>>> [0100], [0200],[0300]....[2400].
>>>
>>> I want to capture the sum of the events by days, evenings and nights
>>> where
>>> "days" = ([0800]+[0900}...+[1500])
>>> "evenings" = ([1700]+[1800]...+[2400])
>>>
>>> I'm trying to create a function for each of "days", "evenings" etc,
>>> I didn't want to have to declare each variable everytime I invoke the
>>> function from a query, thinking an array is the way to go? I'm
>>> hopelessly lost...can an array work with columns or only rows? How do I
>>> reference the column I want in the array?
>>>
>>> Function DaySum() As Double
>>> Dim Days
>>> Days = Array("[0800]", "[0900]"...."[1500]")
>>> DaySum = Days(1) + Days(2)....+ Days(8)
>>> End Function
>>>
>>> If you're not already rolling on the floor laughing at this poor
>>> attempt....thanks for any help or pointers.
>>>
>>>
>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Prevent cell/array references from changing when altering/moving thecell/array nme Microsoft Excel Misc 1 19th Sep 2008 01:53 PM
Redimming an array dynamically assigned from range (how to redim first dimension of a 2-D array? /or/ reverse the original array order) Keith R Microsoft Excel Programming 3 13th Nov 2007 04:08 PM
meaning of : IF(Switch; Average(array A, array B); array A) =?Utf-8?B?RFhBVA==?= Microsoft Excel Worksheet Functions 1 24th Oct 2006 06:11 PM
Pass from C# (framework 1.1) array of delegates to unmanaged DLL as array of function pointers verpeter@gmail.com Microsoft C# .NET 0 23rd Aug 2006 02:20 PM
select variables ranges, copy to array, paste the array in new workbook Mathew Microsoft Excel Worksheet Functions 1 1st Apr 2005 09:40 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:35 PM.