Results 1 to 5 of 5
  1. #1
    ijo68 is offline Novice
    Windows 10 Office 365
    Join Date
    Feb 2021
    Posts
    27

    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 offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    8,551
    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.
    - "doesn't work" doesn't help. Implement changes in copies of your database.
    Iím telling everyone it's good to eat dried grapes. Itís all about raisin awareness.

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    21,684
    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 Novice
    Windows 10 Office 365
    Join Date
    Feb 2021
    Posts
    27
    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,257
    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...
    HTH
    -----
    Steve
    --------------------------------
    "Veni, Vidi, Velcro"
    (I came; I saw; I stuck around.)

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 - Senior Forums