Results 1 to 7 of 7
  1. #1
    Rajah is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    4

    Click button to show query results

    Hello,

    I was looking to have a user click a button that will display results. I want them to create preset queries that they can click a button and it will show up on the form, and they will be able to click the next button to see all the equipment that is located in one location.

    For example:



    I want to create a button on a form that says, "All equipment location starts with a C and is sorted". The first item of the query will show up on the form and the user can click the next button to see all the records.

    Thanks

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    Make your queries,put them in a table...tQrys
    Caption,Qry
    Employees,qsEmps
    All Equipment, qsEquip

    user can pick the query in the combo box,then the button can open it...
    Code:
    sub btnRun_click()
    docmd.openQuery cboQry
    end sub

  3. #3
    Rajah is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    4
    Quote Originally Posted by ranman256 View Post
    Make your queries,put them in a table...tQrys
    Caption,Qry
    Employees,qsEmps
    All Equipment, qsEquip

    user can pick the query in the combo box,then the button can open it...
    Code:
    sub btnRun_click()
    docmd.openQuery cboQry
    end sub
    Hi ranman256,

    This is what I know how to do, but what I want is so when they click on the button the data shows up on the form. This user can page thru the records, and even update a record if needed.

  4. #4
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Have you button open the Form instead of the Query.
    Use the Query as the Control Source of your Form.
    You can use VBA code to change the Query that the Form is using. See: https://docs.microsoft.com/en-us/off...m.recordsource

  5. #5
    Rajah is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    4
    Quote Originally Posted by JoeM View Post
    Have you button open the Form instead of the Query.
    Use the Query as the Control Source of your Form.
    You can use VBA code to change the Query that the Form is using. See: https://docs.microsoft.com/en-us/off...m.recordsource

    Is there a way to change the Control Source by clicking a button on a form?
    I tried the below but it didn't like it.
    =[Forms]![frmCustomers].[RecordSource]=[qrybyloc]

  6. #6
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    The method I most commonly use is defined here: https://www.accessforums.net/showthread.php?t=26592
    Essentially, what I do is build the SQL code on-the-fly using VBA, then assign that SQL code to the query, and then open the query (or the Form/Report that uses that query).

  7. #7
    Rajah is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    4
    Quote Originally Posted by JoeM View Post
    The method I most commonly use is defined here: https://www.accessforums.net/showthread.php?t=26592
    Essentially, what I do is build the SQL code on-the-fly using VBA, then assign that SQL code to the query, and then open the query (or the Form/Report that uses that query).

    Hi Joe,

    This looks like what I can use, let me read this over a couple more times to try to understand it.

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

Similar Threads

  1. Replies: 1
    Last Post: 07-03-2017, 01:14 PM
  2. Show Query Results in 3 Columns
    By WickidWe in forum Reports
    Replies: 6
    Last Post: 12-22-2013, 03:50 PM
  3. Query that show certain results
    By LukeJ Innov in forum Queries
    Replies: 3
    Last Post: 09-03-2013, 03:26 AM
  4. Replies: 24
    Last Post: 02-20-2013, 09:46 PM
  5. Replies: 6
    Last Post: 05-14-2012, 07:24 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