Results 1 to 4 of 4
  1. #1
    DlrMngr is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    12

    Exclamation Query Taking nearly 30 times longer With Param

    Hi,



    I currently have a queries that runs quite nicely and quickly when i enter the between dates within # tags and runs in approx 2 seconds which is exactly the functionality i need.

    Works in 2 Seconds:
    Code:
    Between #12/09/2012# and #13/09/2012#
    However, i need the versatility of users to be able to change and select the dates without having to change the hard code so i refered to using Parameters. Nothing fancy just a popup box asking for a value (will add it to form values once working)

    The same query, the only thing changed is the between dates and it takes over 60 seconds as i had to increase the default ODBC timeout.
    Code:
    Between [Date To Start] and [Date To End]
    i have even tried:
    Code:
    Between DateValue([Date To Start]) and DateValue([Date To End])
    Can anyone assist with a quicker way to add this versatility without having to take so long its part of a monitor and 60 seconds of the Access app hanging just cannot happen as i will have to manually update the date everyday?

    Regards,
    DlrMngr

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    Don't know why so much slower, would have to examine data. Does every record have a date value?

    Personally, don't like and don't use parameter input popups in queries. Is this query to be the RecordSource for a form or report? I prefer the WHERE CONDITION argument of OpenForm/OpenReport method:

    DoCmd.OpenReport "report name", , , "fieldname BETWEEN #" & Me.StartDate & "# AND #" & Me.EndDate & "#"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    DlrMngr is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    12
    Hi,

    Thanks, the query is a record source however there are is a further query between this and the report which performs subqueries which is what the report runs off however i dont think you can send the above, through one query to the second query.

    I am currently thinking about revisiting this and writing in vba to perform the queries with QueryDef try it this way as the length of time is too excessive.

    The table i am reading from is a 12 month summary table, within each 15 minutes summary entry there could be a few hundred records, evidently this is a lot of data and i am wondering if it is pulling all the data and then applying the "paramters" rather than just executing as is?

    Not sure though but its really annoying

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    I agree with june7 that a Form on which you can select -- say Dates from a Calendar control - confirm the selection, then set up OpenArgs etc would give a standard approach and code could ensure the syntax is consistent.

    If you have additional queries after the StartDate, Enddate selection --- suggest you put these on a form (may not be the same form) and again adjust record source or openargs behind the scenes, and run the "report/query whatever your procedure is" in a consistent manner.

    You should be able to test these pieces to make sure things like indexes, sql structures are "quick' (efficient in your view) before going to production.

    Just a few things to consider.

    You may find some ideas at martin green's site
    http://www.fontstuff.com/access/acctut19.htm

    Good luck with your project.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 08-14-2011, 08:35 PM
  2. query for times over differrent days
    By gaz100uk in forum Queries
    Replies: 3
    Last Post: 07-27-2011, 10:06 AM
  3. Passing param. to Report
    By kaledev in forum Programming
    Replies: 5
    Last Post: 01-20-2011, 12:46 PM
  4. Query NOT taking the two parameters WHY?
    By iamraja5 in forum Forms
    Replies: 7
    Last Post: 03-16-2010, 04:29 AM
  5. Query: How many times does a value exist?
    By hognabbt in forum Queries
    Replies: 1
    Last Post: 01-10-2010, 01:33 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums