criteria for cross table query syntax

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Daedalus
    New Member
    • Nov 2006
    • 19

    criteria for cross table query syntax

    I've got two tables of various information about members of a club I'm helping run and I'm now trying to create queries I can use so I won't have to redo filters constantly to extract various information I need.

    Where I have issue is that I create a query that pulls table fields from the two tables (linked via one-to-one relationship), and I need to only see members that are under 18 years old on the date I run the query (due to rules about Minors I need to keep regular updated lists on who they are)

    In the field properties for the BirthDate column in the query I created I go to the Criteria field and enter the following, that I've found listed as example on various online guides:

    Code:
    DateDiff ("yyyy", [BirthDate], Date()) -18
    It gives me syntax error on the first comma as soon as I hit enter or try to leave the field. As far as I can see the formatting is right but I'm quite certain I'm missing something basic that I've completely overlooked here.

    Using Access 2007.
    And am sort of around novice level.
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    I did a direct copy and paste of your code against one of my tables that has a [Birthdate] field without issues; thus, I suspect there's more here than you're seeing.

    With your query open
    Switch to the SQL-View:
    +lower right hand corner, there's an icon for SQL,
    +Ribbon/QueryTools/Results/(dropdown-SQL)
    +In GUI-Designer, right-click on empty area of the table display section, select SQL-View from quickmenu

    Copy and paste the entire SQL to the thread within a code-block.


    Some tips on CTQ: http://allenbrowne.com/ser-67.html

    from the same site, tip on calculating age: http://allenbrowne.com/func-08.html

    Comment

    Working...