Results 1 to 5 of 5
  1. #1
    jnoonan22 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    12

    Question TempVars Slowing Down Query?

    I put together an "input form" with a macro button. It's very simple, using combo boxes in cascading order to allow a user to input query paramaters (as TempVars) and hit the macro button which then closes the form and runs the query with the TempVars applied as criteria to the query fields. For the time being, the query is really simple; no formulas or anything in fields, yet after running it with TempVars, it slowed down dramatically. Is there a reason for this?

    Typically, i would have passed criteria to the query by simply adding a [Value?] in the various query fields needed but this query has a lot of possible values that can be entered and i thought an input form with limited combo box selections would be more friendly for users.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    I do not have experience with TempVars. I have always dimensioned the appropriate sized variable. I have avoided the use of TempVars because of their size. I have always considered them to be expensive.

  3. #3
    jnoonan22 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    12
    What do you mean by "dimensioned the appropriate sized variable"? I'm simply trying to pass values from the form to the query. Is there another method that can do this more simply?

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    You can use the form's name and the control's name in the query. This wil be better performing than reserving space in the computer's memory for a TempVar or another complex data type.

    In VBA, you can declare a variable like this
    Dim strSomeValue as String

    This reserves space in the computer's memory for the String data type. The String data type is a specific size. A smaller variable would be an integer.
    Dim intSomeNumber as Integer

    An integer takes less space than a String. A tempvar is much larger than a string.

    If you reference a bound control in a query, the query will consider the data type the control is bound to.

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    I never use dynamic parameterized queries. However, here is example of how to reference controls as dynamic parameter: http://datapigtechnologies.com/flash...mtoreport.html

    I prefer VBA to construct filter criteria http://www.allenbrowne.com/ser-62.html
    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.

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

Similar Threads

  1. How do you use Tempvars in an Update query?
    By JrMontgom in forum Queries
    Replies: 4
    Last Post: 05-02-2015, 08:43 AM
  2. Function call in query slowing it down
    By sneuberg in forum Queries
    Replies: 2
    Last Post: 10-17-2014, 10:32 AM
  3. How to use Tempvars in query
    By JrMontgom in forum Programming
    Replies: 3
    Last Post: 09-03-2014, 12:36 PM
  4. TempVars.add and make value ID
    By Ruegen in forum Programming
    Replies: 4
    Last Post: 12-31-2013, 06:19 PM
  5. Using TempVars in query
    By jonesy29847 in forum Programming
    Replies: 3
    Last Post: 03-03-2011, 11:07 PM

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