Results 1 to 3 of 3
  1. #1
    TinaCa is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    87

    Data type mismatch in query criteria

    It seems like this comes up alot. I have a date field, i created one column for days and one for month year. On the one for days i need all the days <=1 and >=15 but i am getting the error. If I remove it - no error if i put = 1 i get the error.

    The statement is
    ExDat: Format([ExtraDate],"dd")

    Criteria: <=1 and >=15



    The second one is
    ExMthYr: Format([ExtraDate],"mm/yyy")

    Criteria: =Format(Date(), "mm/yyyy")

    It's the first one that giving the error.

    This seems so simple

  2. #2
    TinaCa is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    87
    used datepart instead of format and now it works.

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Thanks for posting your solution. To expand on the problem, the Format() function returns a string, and you had numeric values in the criteria, hence the error. An alternative to DatePart() would be the Day() function, which also returns a numeric value. Day() is simpler, DatePart() more flexible; either should work fine.
    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. Replies: 2
    Last Post: 05-17-2011, 02:40 PM
  2. Data type mismatch in criteria expression
    By Douglasrac in forum Forms
    Replies: 3
    Last Post: 11-23-2010, 10:46 AM
  3. Data type mismatch in query
    By thart21 in forum Queries
    Replies: 8
    Last Post: 10-01-2010, 01:40 PM
  4. data type mismatch in criteria expression
    By broecher in forum Access
    Replies: 4
    Last Post: 09-10-2010, 08:29 AM
  5. Data type mismatch in criteria expression
    By shexe in forum Queries
    Replies: 2
    Last Post: 09-01-2010, 12:47 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