Results 1 to 10 of 10
  1. #1
    Suregrip is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2014
    Posts
    5

    Have subform display query results with command button.

    Hi All looking for an answer to what I thought was going to be an easy task...
    I have a form with a subform (FindBuffer_Form) which I built from a Query (FindBuffer_Query) within the query criteria I have the following (Like "*" & [Select the main Batch Number] & "*")in order to search a particular number.
    I want to be able to run the Query from a command button on the main form and have the results appear in the subform, If I have the Source object of the subform set to Query.FindBuffer_Query I get prompted twice to answer the Criteria before the form opens, after the form opens the subform is generated as per the search criteria.


    Ideally I want the form to open with no data in the subform run the query from command button and have the result in the subform.
    I have not been able to find a solution trawling the web, any help greatly appreciated.
    Thanks in advance.
    Suregrip

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Is the main form bound? Is the subform related to main form by master/child links?

    If not, why not a single form in Continuous view with the filter input control in the form header?

    If you don't want data to show when the form opens, don't use LIKE and wildcard, use =.
    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
    Suregrip is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2014
    Posts
    5
    Thanks for the reply,
    No the main form is not bound and I don't have any relationships between the two, the main form has a number of command buttons which adds different data to the main database with different criteria, I want to be able to open the form and have the user select the appropriate command button to add/amend or view the data available.
    The form will not be open all the time but called up from a link when required, could you explain why the search criteria opens before the form loads?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Subform loads before main form - I know, weird, but that's the way it is.

    Try single form as suggested.
    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
    Suregrip is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2014
    Posts
    5
    Hi
    As suggested have single form with view set to Continuous Forms and command buttons in header, looks great however when I run (FindBuffer_Query) a new datasheet opens with the results but does not update the form, I need to run the query and have the results update the form view not open a new sheet.

  6. #6
    lucychan is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2014
    Posts
    2
    Just checkout the forms connection.. It will shortout.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    What is FindBuffer_Query? Is it just a SELECT query? Don't need to open query. Change the code so it does not open the query, just requery the form. I use only VBA, no macros. VBA code would be:

    Me.Requery

    I don't use dynamic parameterized queries. I use VBA code that sets the form Filter and FilterOn properties. http://www.allenbrowne.com/ser-62code.html
    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.

  8. #8
    Suregrip is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2014
    Posts
    5
    Thanks for looking at This.. I'm quite new to Access and haven't quite got to grips with it all
    FindBuffer_Query is a select query built using the wizard so all code is in SQL, so I guess it's independent that's why it opens a new sheet.
    The query asks for a specific number within the (Order Field) hence (Like "*" & [Select the main Batch Number] & "*") and returns all values associated with the query.
    How do I associate the Me.Requery to run the code and update the view on the form?

  9. #9
    Suregrip is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2014
    Posts
    5
    Resolved with [Forms("FindBuffer_Table").Requery]...
    Oh so simple when you look in the right direction, thanks for all your help guys.
    Suregrip.

  10. #10
    lucychan is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2014
    Posts
    2
    Now you problem is easily shortout and cleared.. Just a one line created such a big problem.
    tomb raider casino

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

Similar Threads

  1. Replies: 9
    Last Post: 10-30-2014, 12:31 PM
  2. Replies: 3
    Last Post: 05-02-2013, 10:36 AM
  3. Replies: 6
    Last Post: 10-11-2012, 02:19 PM
  4. Display QUERY results into SUB FORM
    By taimysho0 in forum Programming
    Replies: 9
    Last Post: 11-23-2011, 12:26 PM
  5. Display Query Results on a Form
    By P5C768 in forum Queries
    Replies: 5
    Last Post: 05-04-2010, 11:04 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