Results 1 to 4 of 4
  1. #1
    saechaoc is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Sep 2015
    Posts
    2

    Variables in query field

    I want this to always call the last month but it does not evaluate the formula instead it treats it as an expression.



    [Logility_Table]![ACTD Format(DateAdd("m",-1,Date()),"m/yyyy")]

    This Format(DateAdd("m",-1,Date()),"m/yyyy") by itself brings in 8/2015 and I want [Logility_Table]![ACTD 8/2015]

    Any ideas on how to dynamically query this data or would it be better to make a SQL string in VBA?

    Thank you.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Cannot reference table/query directly like that. Options are to join tables in query or domain aggregate functions (DLookup, DMax, DMin, DSum, etc) or open recordset in VBA.

    Where are you trying to do this?
    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
    saechaoc is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Sep 2015
    Posts
    2
    Thats good to know thank you ! I'll just do it in VBA then which should work correct?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    If you still have issues, post your attempted code for analysis.
    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. Practical problem variables in query
    By Pluven in forum Queries
    Replies: 5
    Last Post: 04-20-2012, 12:43 AM
  2. Replies: 7
    Last Post: 03-14-2012, 10:56 AM
  3. Using date variables from table in query
    By Skybeau in forum Access
    Replies: 1
    Last Post: 12-22-2011, 08:46 PM
  4. Replies: 9
    Last Post: 02-17-2011, 03:33 PM
  5. Append Query using variables
    By hawg1 in forum Queries
    Replies: 2
    Last Post: 06-09-2010, 08:59 AM

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