473,385 Members | 1,357 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Dynamic Form to Filter Queries by Month & Year combo boxes

SueHopson
47 32bit
Table: tbl_data contains the following fields
qry_rpt_src_MonthlyRenewals contains the same fields
Expand|Select|Wrap|Line Numbers
  1. ID    Firstname    LastName    StartDate    EndDate
  2. 1    First1    Last1    01/08/2018    01/08/2018
  3. 881    First2    Last2    09/05/2019    27/06/2019
  4. 1126    First3    Last3    12/07/2019    30/06/2020
  5. 1208    First4    Last4    07/08/2019    31/07/2020
  6. 1364    First5    Last5    16/09/2019    31/07/2020
  7. 1532    First6    Last6    25/10/2019    30/09/2020
  8. 1976    First7    Last7    05/02/2020    31/01/2020
  9. 1983    First8    Last8    05/02/2020    31/10/2020
  10. 1984    First9    Last9    31/01/2020    31/08/2020
  11.  
I would like to create a form with prepopulated combo boxes that the user can select to filter the end date of the query by Month and Year (not always current month and year)

Currently I have frm_Admin_Reports which displays the following Unbound combo boxes
cbo_SearchMonthFilter
Expand|Select|Wrap|Line Numbers
  1. SELECT zz_frm_SearchMonths.SearchMonth, zz_frm_SearchMonths.SearchMonthName FROM zz_frm_SearchMonths ORDER BY zz_frm_SearchMonths.SearchMonth; 
  2.  
Table: tbl_zz_SearchMonth contains the following fields
Expand|Select|Wrap|Line Numbers
  1. SearchMonth    SearchMonthName
  2. 01    January
  3. 02    February
  4. 03    March
  5. 04    April
  6. 05    May
  7. 06    June
  8. 07    July
  9. 08    August
  10. 09    September
  11. 10    October
  12. 11    November
  13. 12    December
  14.  
cbo_SearchYearFilter
Expand|Select|Wrap|Line Numbers
  1. SELECT [zz_frm_SearchYear].[SearchYear] FROM zz_frm_SearchYear ORDER BY [SearchYear]; 
Table: tbl_zz_SearchYear
Expand|Select|Wrap|Line Numbers
  1. SearchYear
  2. 2018
  3. 2019
  4. 2020
  5. 2021
  6. 2022
  7. 2023
  8. 2024
  9. 2025
  10.  
I know there is a way to merge the search fields to pull all records with that expiry date from the query using a button-run macro, but it's been so long since I've done this I simply can't remember.

Suggestions for simplifying also appreciated. Please do not suggest simply editing in the query as the end users are incapable.
Feb 6 '20 #1
6 2088
twinnyfo
3,653 Expert Mod 2GB
Just include a WHERE clause that includes your search criteria based upon both Combo Boxes.
Feb 6 '20 #2
SueHopson
47 32bit
If I could remember "WHERE" that goes, that would most likely solve my problem (ie, VBA query, access renewal query, etc) :) Since I can't, a little more guidance would be helpful.
Feb 6 '20 #3
twinnyfo
3,653 Expert Mod 2GB
The WHERE clause goes right before your ORDER BY clause.
Expand|Select|Wrap|Line Numbers
  1. "WHERE Year([EndDate]) = '" & Me.cbo_SearchYearFilter & _
  2.     "' AND Month([EndDate]) = '" & Me.cboSearchMonthFilter & "' "
You will have to convert my smart quotes to straight quotes. My iPad doesn’t know how to be dumb....

Hope this hepps.
Feb 6 '20 #4
NeoPa
32,556 Expert Mod 16PB
I'd do it a little differently. If, as you say, you don't want the query (ies?) to be updated then include references in your queries to the Form Controls directly.

I don't often advise this as it creates dependencies that can cause you headaches later on, but if they're your restrictions then this is a possible route.

Expand|Select|Wrap|Line Numbers
  1. SELECT ...
  2. FROM ...
  3. WHERE (Format([EndDate],'yyyymm')=Forms!frm_Admin_Reports!cbo_SearchYearFilter & Forms!frm_Admin_Reports!cbo_SearchMonthFilter)
Feb 7 '20 #5
SueHopson
47 32bit
My thanks to you both, I've had a chance to review and while both are excellent suggestions for this group/build I think NeoPa's suggestion will be more effective.

While I can now get the report to open, regrettably it is not displaying any records and I am certain it has to do with the End-Date format. When manually manipulating the query directly, the [End_Date] format is dd/mm/yyyy and the Criteria used was Like "*/01/2020" (as an example).

I've tried manipulating the Format [End_Date] field, but nothing seems to be effective. Suggestions?
Feb 11 '20 #6
NeoPa
32,556 Expert Mod 16PB
Hi Sue.

While this question may appear to be connected, as in that it's connected to the same work you're doing, technically they are different issues, thus a new thread is required to ask this.

Feel free to link to this one in your new thread if you believe it may add helpful context.
Feb 13 '20 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Catherine | last post by:
I am trying to create a report that will give me q total count by month to date, and then another by year to date. Example: Discharges By Type Month To Date Year To Date...
1
by: jon.ingram | last post by:
I have a main menu that contains 2 drop down boxes. Drop down 1 contains: BSL USL Drop down 2 contains: 1 2 3
2
by: Burghew | last post by:
Thanks for the previous replies..... What I need is to generate invoices for customers whom we rent out equipment. I will be choosing the date and year say for December 2005 print the invoices...
4
by: Miguel | last post by:
I have an order entry database with two forms. One is for new orders the other is to update orders. The forms are identical except that one is strictly order entry. On both forms are three sets of...
4
by: smugcool | last post by:
hi, i have a form in which a text field txtDate is there. Where user fills up a date. suppose sombody enters a date 23.oct.07 in this text field, i wanted to get only month and year...
3
by: tasawer | last post by:
Hi, I have an accident claims form that I need to requery on one of three different fields. Primary field is AccidentID ClientName (Can appear on more than one AccidentID) SolicitorsRef...
1
by: Nicodemas | last post by:
I am trying to figure out a query. I believe it is possible, but my SQL knowledge has been waning in the past year due to disuse. Anyone wish to help? I have three tables. Table: Fruits ...
1
by: Fahhad | last post by:
I have created a database with two fields "EmpID" (int) and "LeaveDate (DateTime) using SQL Server 2005. How Do I modify the below Stored Procedure to find the total working days for an employee...
4
by: Stoic | last post by:
Hi, I have a database with tables and fields. I have created a form that with three to four combo boxes and inserted a control button. I would like a write a code to query my data based on the...
1
by: jeannier1975 | last post by:
Iwould like to create a form in which a listbox displaying records from Projects is filtered based on the selection of a comboboxs Dept and Tech , Date From and DateTO combo boxes containing the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.