Results 1 to 6 of 6
  1. #1
    mshaynerush is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2012
    Posts
    4

    Please help with syntax

    I would like to use DLookUp to pull the month from the month field in a query. The query formats the month as full month, January, February, etc...



    Here is my attempt. Can you please give me the proper syntax:

    Code:
    =DLookUp("[Total Verifications]","[qryTotalInspectionsByMonthYTD]","Format([Month],"mmm")=" &[Reports]![rptMonthlyVTeam]![hidDate] & ")
    The report textbox hidDate has code in it that will format the current month as "mmm" : this is what drives hidDate.
    =Format(Date(),"mmm")

    the query i'm pulling from counts the amount of inspections in a given month and I need to pull that number into a text box within my report. For nothing else, i'd like to learn the syntax.

  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,930
    If the field is text, use apostrophe delimiters on the criteria:

    =DLookUp("[Total Verifications]","[qryTotalInspectionsByMonthYTD]","Format([Month],"mmm")='" & [Reports]![rptMonthlyVTeam]![hidDate] & "'")

    If a date, use #, nothing for number.

    Where are you using this expression? Why does it reference a control on report for input?
    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
    mshaynerush is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2012
    Posts
    4
    I am creating a monthly report that will query the database using a 30 day range, so the number generated from this DLookUp will total the amount of inspections in a 30 day range. The domain of the DLookUp counts the inspections and groups by months for the year, so I'm attempting to grab only the month field from that query that matches the current month so that I don't have to use a drop down selection to run a report, i can just open the report from the main console of my database and have it ready to go. basically.

    My problem, now that I look closer, is that the query returns the month already formatted as the whole month, "October" so I need to make the field = the same thing as my hidDate field, whose value is =Format(Date(),"mmmm") to update the month as the month changes.

    Sorry for the confusion.

  4. #4
    mshaynerush is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2012
    Posts
    4
    Why can't I just make the control source the query itself? that doesn't seem to work.

  5. #5
    mshaynerush is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2012
    Posts
    4
    I'm sorry to bother you. Your answer did help quite a bit, actually, but this is what i used that works:

    Code:
    =DLookUp("[Total Verifications]","[qryTotalInspectionsByMonthYTD]","[Month]='" & [Reports]![rptMonthlyVTeam]![hidDate] & "'")

  6. #6
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Actually, we very much appreciate when the original poster posts the answer that worked. Thanks!

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

Similar Threads

  1. Help with syntax
    By Gizmodo in forum Queries
    Replies: 4
    Last Post: 11-16-2012, 01:45 PM
  2. Help with syntax
    By accesskid in forum Forms
    Replies: 3
    Last Post: 06-02-2011, 05:14 AM
  3. Help with syntax
    By GWB in forum Queries
    Replies: 4
    Last Post: 01-26-2011, 03:33 PM
  4. Incomplete Syntax Clause (syntax error)
    By ajetrumpet in forum Programming
    Replies: 4
    Last Post: 09-11-2010, 10:47 AM
  5. Please help SQL Syntax
    By jordanturner in forum Access
    Replies: 4
    Last Post: 09-02-2010, 08:05 AM

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