Results 1 to 5 of 5
  1. #1
    tagteam is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    501

    Open form with filter value from Table

    I have a temp table that i am using to complete some tasks. I have to use it so that close my form and run an update query. Then when i open the form back up I want to go back to the record it was on when closed. I have that record id in the temp table.



    in the past I have used the following
    DoCmd.OpenForm FormName:="Myform", WhereCondition:="[ID]='" & Me.ID & "'"

    however, the form is not open now and I need to open it based on the value in the temp table.
    I have tried

    DoCmd.OpenForm FormName:="Myform", WhereCondition:="[ID]='" & TempTable.ID & "'"

    But that does not work

  2. #2
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    I have to use it so that close my form and run an update query.
    Can you explain this part? Can you just run the update query, then requery/refresh the form without closing it?

  3. #3
    tagteam is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    501
    Each time I try to run the update query with the form open it fails due to lock violations so I had to close the form to get the data to update.

  4. #4
    tagteam is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    501
    The update query will run if i just double click on it in the navigator but if I start it up in vba from an on click action I get the lock violations. I am not sure why it will run when not cued up by vba but wont when it is in my code!

  5. #5
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,741
    If there are more than one record in the temptable, you will have to specify which record to look at.
    Another approach would be to store the ID in a tempvar (Tempvars!tvMyID = Me.ID.value) before closing the form.
    Then
    docmd.openform "MyForm",,,"ID =" & tempvars!tvMyID

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

Similar Threads

  1. Replies: 8
    Last Post: 10-22-2015, 05:18 PM
  2. Filter form on open
    By Xarkath in forum Forms
    Replies: 8
    Last Post: 07-17-2013, 10:51 AM
  3. filter when i open form
    By Balen in forum Forms
    Replies: 0
    Last Post: 08-12-2010, 02:31 PM
  4. How to open a form with filter applied?
    By rkm360 in forum Access
    Replies: 1
    Last Post: 03-18-2009, 09:27 AM
  5. Open a table in a From based on a filter
    By turbobeagle in forum Forms
    Replies: 1
    Last Post: 01-11-2008, 12:27 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