Results 1 to 5 of 5
  1. #1
    ijo68 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Feb 2021
    Posts
    37

    How to get this query result in a form instead of in Datasheet view


    I have a Form which I am using to enter the Criteria for this Query. it works great but displays the result in datasheet ., is there a way to use to cmd button to send the result to a form bound to that query instead of datasheet? .. Any help will be much appreciated.. Thank in advance.Click image for larger version. 

Name:	query1.jpg 
Views:	11 
Size:	42.9 KB 
ID:	44392
    Click image for larger version. 

Name:	form1.jpg 
Views:	10 
Size:	23.7 KB 
ID:	44391

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I presume your query references the fields in the 1st form.
    Don't open the query. Create a form based on the query and use the button to open the new form. The downside is that if keeping it that simple, the form will open regardless of whether or not the search form fields have data in them. Opening the form from the nav pane will also run the query. If you're OK with those quirks, then it should be that simple. If not, you'll need to tweak the approach.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  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
    Create a form bound to the query, and open it from the button instead of the query.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    ijo68 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Feb 2021
    Posts
    37
    Great It works great .. I'll put some code for 0 records in the on-open event to cancel sub if it has no data .. thank you both.

  5. #5
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Basically, you are filtering your data.

    Design a form, using the query as the form record source. Remove the criteria in the query.
    Add the fields from the query to the form detail section. Set the form default view to Continuous Forms

    In the form header, add the unbound combo box for the territory. (cboTerr)
    Add a button in the header. The click event of the button would have code
    Button name -> "btnFilter"
    Caption -> "Filter"
    Code:
    Private Sub btnFilter_Click()
        Me.Filter = "Territory = '" & Me.cboTerr & "'"
        Me.FilterOn = True
    End Sub
    Add another button to remove filter
    Button name -> "btnNoFilter"
    Caption -> "Remove Filter"

    Code:
    Private Sub btnNoFilter_Click()
        Me.Filter = vbNullString
        Me.FilterOn = False
    End Sub

    I don't know if cboTerr is a number or text. If cboTerr returns a number, change
    Code:
        Me.Filter = "Territory = '" & Me.cboTerr & "'"
    to
    Code:
        Me.Filter = "Territory = " & Me.cboTerr

    Drat! Late again...

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

Similar Threads

  1. Replies: 9
    Last Post: 01-12-2016, 03:48 PM
  2. Replies: 3
    Last Post: 08-18-2013, 09:14 PM
  3. Replies: 3
    Last Post: 03-25-2013, 02:01 PM
  4. Replies: 6
    Last Post: 11-21-2012, 05:10 PM
  5. Replies: 16
    Last Post: 09-12-2012, 08:39 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