Results 1 to 4 of 4
  1. #1
    sberti is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    33

    TempVars Returns Strange Result

    Hi,
    I'm using Access 2013 on a Windows 10 PC.
    I have a Form with txtStartDate and txtEndDate controls with a datasheet subform that I want to filter using those dates.
    It also has a button, cmdUpdate, that has a Macro associated with it.

    I have set the macro to SetTempVars for the txtStartDate and txtEndDate called tmpStartDate and tmpEndDate.

    I have been attempting to use tmpStartDate and tmpEndDate in the criteria of a Date field in a query to filter the data. (Using "Between")



    It would not work and finally I decided to see what the Temporary Variables were returning. So, in the macro I made a Message Box to display the tmpStartDate and tmpEndDate.

    The result has me puzzled. Instead of displaying the values of txtStartDate and txtEndDate, the Message box displays just a Year for each, that does not seem to be related to anything.

    For example, when the txtStartDate is 2015-08-05 and the txtEndDate is 2015-08-30, the message box displays the tmpStartDate as 2002 and the tmpEndDate as 1997.

    I have used TempVars in the criteria of queries before, so I don't understand what is wrong. This is the first time I've tried it with Windows 10. Could this be a Windows 10 date issue?

    Does anyone have any suggestions? I'd appreciate any help.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The results you're seeing (2002 & 1997) are likely because Access is doing math (2015 minus 8 minus 5 is 2002). I don't use TempVars, but make sure your textboxes have a date format so Access will recognize them as dates. I simply refer to the textboxes in my queries.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    sberti is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    33
    Thanks for the reply. I hadn't thought of that. But my text boxes do have date formats. But this gives me a direction to check out.
    My form is a subform in a Navigation form, which kind of complicates using the data in the controls as criteria for queries more than regular forms.
    Thanks!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problem, post back if you're still stuck. I don't use TempVars but a quick search would seem to indicate you can use them the way you're trying to. Maybe you can attach the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. How to use Tempvars in query
    By JrMontgom in forum Programming
    Replies: 3
    Last Post: 09-03-2014, 12:36 PM
  2. TempVars.add and make value ID
    By Ruegen in forum Programming
    Replies: 4
    Last Post: 12-31-2013, 06:19 PM
  3. Replies: 9
    Last Post: 05-08-2013, 02:37 PM
  4. Using TempVars in query
    By jonesy29847 in forum Programming
    Replies: 3
    Last Post: 03-03-2011, 11:07 PM
  5. Replies: 6
    Last Post: 03-17-2010, 10:09 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