Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Looking for faster way to find minimum value

I have an application that stores values on 15 minute intervals. In one
function, I need to find the minimum average value over a 3 hour
period. So I make a query for each 3 hour period, compare it to the
last period, and save it if it has a lower value. The time is
tolerable, but pretty annoying (about 25 seconds). I want to know if
anyone has any suggestions for speeding up this process. My code is
below. Thanks!!


Do
EndAM = StartAM + #3:00:00 AM#

'Query with records during this 3 hour period
strQry = "SELECT INFLOW.FM_FLOW FROM inflow WHERE
(((Int([INFLOW]![FM_DATE]))=#" + Format(dtForm, "mm-dd-yy") + "#) AND
((INFLOW.FM_FMID)=" + strFMID + ") AND
((([INFLOW]![FM_DATE]-Int([INFLOW]![FM_DATE])))=#" + Format(StartAM,
"ttttt") + "# And (([INFLOW]![FM_DATE]-Int([INFLOW]![FM_DATE])))<#" +
Format(EndAM, "ttttt") + "#));"
If fQueryExist(qryName) Then db.QueryDefs.Delete qryName

Set qdfAM = db.CreateQueryDef(qryName, strQry)

'Find average value for this 3 hour period
tmpAvgAM = DAvg("fm_FLOW", qryName)
If AvgAM tmpAvgAM Then
AvgAM = tmpAvgAM
End If
tmpAvgAM = 0
StartAM = StartAM + IntervalAM
db.QueryDefs.Delete qdfAM.Name
Set qdfAM = Nothing

Loop While EndAM < LastAM

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Looking for faster way to find minimum value

Yes, database is in ms access. With the parameters, the values come
from a form. I call the function from a couple different forms, so I
can't name the form specifically in the query. I also have at least 2
forms open. How can I pass the values to the query? Thanks!

witek wrote:
wrote:
I have an application that stores values on 15 minute intervals. In one
function, I need to find the minimum average value over a 3 hour
period. So I make a query for each 3 hour period, compare it to the
last period, and save it if it has a lower value. The time is
tolerable, but pretty annoying (about 25 seconds). I want to know if
anyone has any suggestions for speeding up this process. My code is
below. Thanks!!


Do
EndAM = StartAM + #3:00:00 AM#

'Query with records during this 3 hour period
strQry = "SELECT INFLOW.FM_FLOW FROM inflow WHERE
(((Int([INFLOW]![FM_DATE]))=#" + Format(dtForm, "mm-dd-yy") + "#) AND
((INFLOW.FM_FMID)=" + strFMID + ") AND
((([INFLOW]![FM_DATE]-Int([INFLOW]![FM_DATE])))=#" + Format(StartAM,
"ttttt") + "# And (([INFLOW]![FM_DATE]-Int([INFLOW]![FM_DATE])))<#" +
Format(EndAM, "ttttt") + "#));"
If fQueryExist(qryName) Then db.QueryDefs.Delete qryName

Set qdfAM = db.CreateQueryDef(qryName, strQry)

'Find average value for this 3 hour period
tmpAvgAM = DAvg("fm_FLOW", qryName)
If AvgAM tmpAvgAM Then
AvgAM = tmpAvgAM
End If
tmpAvgAM = 0
StartAM = StartAM + IntervalAM
db.QueryDefs.Delete qdfAM.Name
Set qdfAM = Nothing

Loop While EndAM < LastAM


Where is database? in ms access?
Don't build query dynamically,
write a query with paramaters and run it passing parameters only.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find minimum value caroline Excel Worksheet Functions 1 March 7th 08 06:25 PM
Find minimum value in column. dlbeiler Excel Worksheet Functions 3 October 12th 07 05:55 PM
Find minimum value greater than a particular value John Michl Excel Worksheet Functions 3 April 27th 06 07:10 PM
Can faster CPU+larger/faster RAM significantly speed up recalulati jmk_li Excel Discussion (Misc queries) 2 September 28th 05 10:24 AM
How to find the minimum value in a database with multiple values . billybob1 Excel Discussion (Misc queries) 2 January 26th 05 06:11 PM


All times are GMT +1. The time now is 03:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"