Results 1 to 11 of 11
  1. #1
    Danroved is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Nov 2018
    Posts
    6

    DoCmd.Open form issus


    I am trying to filter ProjectID's in qryStartDates where Year = cboYear.value and filter these projectID's into my frmProject:

    DoCmd.OpenForm "frmProjects", ,"qryStartDates" , "Year=" & cboYear.value

    How can I make this work?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Year is a reserved and should not use reserved words as names for anything. If you do, enclose in [ ].

    Don't use both FilterName and WhereCondition arguments. I have NEVER used FilterName.

    DoCmd.OpenForm "frmProjects", , , "[Year]=" & Me.cboYear
    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
    Danroved is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Nov 2018
    Posts
    6
    Thank you June7.
    Where do I specify the qryStartDate where the ProjectID will be retrieved from and used as a filter for frmProject?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Not sure what you are asking. Include as many filter parameters as you want in the WhereCondition.

    On reflection, maybe FilterName and WhereCondition arguments will work together. Never actually tried.
    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.

  5. #5
    Danroved is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Nov 2018
    Posts
    6
    let me explain:
    My application opens up a form called frmProjects.
    i have a table that has all my projects listed where frmProjects gets the data from.
    I have a query called qryStartDate where I can get all the projectID's for year 2018.
    How can I write an open form statement that would allow me to do this?

  6. #6
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    I have a query called qryStartDate where I can get all the projectID's for year 2018.
    If that query contains all the fields needed in your form, just make it the recordsource for the form. All done.

  7. #7
    Danroved is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Nov 2018
    Posts
    6
    I dont want to change my form recordsource this is why i am trying to run a filter.

  8. #8
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    If you want to filter on year 2018 and qryStartDates contains only 2018 dates, the where criteria is redundant. Try
    DoCmd.OpenForm "frmProjects", ,"qryStartDates"

    If you get an error, kindly let us know exactly what it is.

  9. #9
    dashiellx's Avatar
    dashiellx is offline Falconer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Location
    Baltimore
    Posts
    49
    Check out Dynamic Query Examples. That should help you understand how to build where clauses and filters.

  10. #10
    Danroved is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Nov 2018
    Posts
    6
    if the query has a criteria how do I pass the criteria value
    DoCmd.OpenForm "frmProjects", ,"qryStartDates"

  11. #11
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Post the query SQL statement.

    If you want to provide db for analysis, follow instructions at bottom of my post.
    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. Replies: 2
    Last Post: 06-10-2018, 05:37 AM
  2. Replies: 10
    Last Post: 08-14-2017, 11:11 AM
  3. Replies: 1
    Last Post: 02-09-2016, 07:03 AM
  4. docmd.open form between dates condition
    By Ruegen in forum Programming
    Replies: 6
    Last Post: 09-22-2013, 11:23 PM
  5. Select / DoCmd to open another form
    By chrisjack001 in forum Access
    Replies: 1
    Last Post: 08-24-2010, 12:31 PM

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