Results 1 to 4 of 4
  1. #1
    sovereign is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    May 2015
    Posts
    30

    Docmd.openform (date) and (text)

    Afternoon,

    I am trying to open a form with multiple conditions, they work perfectly on there own but when i combine i get a type mismatch error.


    Code:
    DoCmd.OpenForm "frmdashboardall", , , "[A_EventsCreatedOn]<= date()-7"
    and



    Code:
    DoCmd.OpenForm "frmdashboardall", , , "[Pstatus] = 'New Claim'"
    But obviously i need the code combined. I tried adding AND in the middle of the two criteria but it didn't work.

    Any help??

  2. #2
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    it should do

    Code:
    "[A_EventsCreatedOn]<= date()-7 AND [Pstatus] = 'New Claim'"

  3. #3
    sovereign is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    May 2015
    Posts
    30
    ah! so simple I was wrapping each one on " " so think that's where I was going wrong! Thank you!

    Quick one also, is it possible to use "last()" or "Max()" in the criteria?

    regards

  4. #4
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    Quick one also, is it possible to use "last()" or "Max()" in the criteria?
    not in the accepted sense as used in a group by query, but you can use such a group by query in your criteria

    e.g. "[A_EventsCreatedOn]=(SELECT Max([A_EventsCreatedOn]) FROM myTable as T)"

    or this will return the records for the top 10 dates "[A_EventsCreatedOn] IN (SELECT Top 10 [A_EventsCreatedOn] FROM myTable as T ORDER BY [A_EventsCreatedOn] Desc)"


    or use one of the domain functions

    e.g. "[A_EventsCreatedOn]=DMax('[A_EventsCreatedOn]','myTable')"

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

Similar Threads

  1. DoCmd.OpenForm; 3rd Argument = FilterName
    By Access_Novice in forum Programming
    Replies: 1
    Last Post: 02-02-2014, 11:05 PM
  2. Slow Opening Form using DoCmd.OpenForm
    By timfoster in forum Forms
    Replies: 12
    Last Post: 02-01-2014, 04:00 AM
  3. DoCmd.OpenForm Syntax Error
    By alsoto in forum Forms
    Replies: 3
    Last Post: 02-29-2012, 01:14 PM
  4. What actually happens at docmd.openform
    By Beorn in forum Programming
    Replies: 4
    Last Post: 01-05-2011, 02:19 PM
  5. DoCmd.OpenForm Modification
    By alsoto in forum Forms
    Replies: 6
    Last Post: 05-01-2009, 07:28 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