Results 1 to 14 of 14
  1. #1
    Appollobsg75 is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2022
    Posts
    13

    Query Parameters


    Hello, I have a database, i have a few queries and the way the queries are setup is they pull Degree, Branch and Graduation date. Right now in the criteria of the Graduation Date column in my query I have a parameter between [enter start date] and [enter end date], but i want to also pull the Branch associated with the grad date, i then want to put this into a chart. at this time when i try and put into my or criteria under branch i'm able to pull the branch and grad date, but when i go to put them into the chart it tells me that Microsoft does not recognize [enter start date]. If possible can anyone give me a good way of pulling the information and of putting it into a chart?

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Create a form with unbound textboxes where you enter the Start and End dates and an unbound combo to select the branch. Use those in your query. You might need to open the query in design view, click on Parameters on the Design Ribbon and add the two\three parameters and set their data types.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    use the full path to the text box ,usu:
    forms!fMyForm!txtStartDate

    the BUILDER will always spell it right for you.

  4. #4
    Appollobsg75 is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2022
    Posts
    13
    I will give it a try. Thank you very much.

  5. #5
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Have a look at this, should help you understand the concept:https://docs.microsoft.com/en-us/off...-qbf-technique

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  6. #6
    Appollobsg75 is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2022
    Posts
    13
    Thanks for you time and information. The suggestion was a good, but I think I'm looking for something else. I mean I might be not too sure. You guys are the experts and I'm trying to relay what I can using my own verbiage so I'm sorry if I might be wrong or off the reservation. I have included my DB this time, cause I was hoping that you would take a look. I have a form called CAHS Graduates Charts and On that form I have 4 charts that each access a different query, what I'm trying to do is update all of them by using a date range, i tried to put a parameter on each query to update but that does not work on form. Is there anything else I might be able to try?CAHS Graduates Statistical Test.zip

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,944
    You could use tempvars in all the queries, and just set the tempvars to relevant values
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  8. #8
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Please have a look at the updated file. When using crosstab queries with parameters you need to explicitly set their data type in query design in the Parameters window.

    Cheers,
    Attached Files Attached Files
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  9. #9
    Appollobsg75 is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2022
    Posts
    13
    Mr. Cucinschi, that works great. Can I create a form with unbound txt box that allows the user to enter in the branch they want to query along with the date range and then display that in a chart form? I have tried to put in the query column for the branch something like "ARMY*" and then under graduation date i put in the or section of that column the between date range, but it will not pull both accordingly. it only pulls the first criteria which is ARMY. Can I use more than one Criteria?

  10. #10
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Here you are, select branch or leave combo empty for all.

    Cheers,
    Attached Files Attached Files
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  11. #11
    Appollobsg75 is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2022
    Posts
    13
    Thanks Mr. Cucinschi that is perfect for what I need. I ran into something else, i noticed when I ran certain date ranges it brought up no chart. so when i checked my data i found that in that date range for that branch there were not degrees. Is there a way to show a msgbox stating "no graduate found"? For example i did a date range form 10/01/2021 to 11/01/2021 and select Navy, but no chart came up. I tried to add is null into the select statement for the query and then a msgbox but that did not work either. Can i not added an is null then msgbox "no graduates found" to my existing query?

  12. #12
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    You can use dCount to check if the source query returns records and display your message if not (needs to go before opening the form):
    Code:
    If dCount("*","qryBranchGrads")=0 Then
        Msgbox "No graduates found!"
        Exit Sub
    End If
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  13. #13
    Appollobsg75 is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2022
    Posts
    13
    That works perfectly, Thank you very much.

  14. #14
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Replies: 2
    Last Post: 11-28-2016, 09:49 PM
  2. Parameters in a query?
    By Carol Geddes in forum Queries
    Replies: 5
    Last Post: 11-05-2013, 05:00 PM
  3. Query/data parameters
    By sk88 in forum Access
    Replies: 2
    Last Post: 07-26-2012, 12:58 PM
  4. query help with parameters
    By Madmax in forum Access
    Replies: 2
    Last Post: 03-05-2012, 03:07 PM
  5. Replies: 3
    Last Post: 07-01-2010, 07:55 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