473,385 Members | 1,927 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.

Query based on month of record

If all my records have a date on them for when they were entered, how can I create a query that will pull those records entered within a selected month/year?
Using of course a combobox for the user to select the month/year, or a calendar box.
Jan 16 '13 #1
2 1375
Seth Schrock
2,965 Expert 2GB
If you are just looking for the month and year, then you would need to use a combination of the Year(), Month() and possibly MonthName() functions. Lets say your date field is called DateEntered and you have cboMonth and cboYear for your combo boxes. If your months combo box is tied to a number (the number of the month, ie. 1 = January, 7 = July, etc.) then your WHERE clause of your query would look something like this:
Expand|Select|Wrap|Line Numbers
  1. WHERE Year(DateEntered) = cboYear
  2. AND Month(DateEntered) = cboMonth
If your month combo box is just a list of names, then your WHERE clause would look something like this:
Expand|Select|Wrap|Line Numbers
  1. WHERE Year(DateEntered) = cboYear
  2. AND MonthName(Month(DateEntered)) = cboMonth
Jan 16 '13 #2
NeoPa
32,556 Expert Mod 16PB
Your WHERE clause would be similar to :
Expand|Select|Wrap|Line Numbers
  1. WHERE (Format([DateField],'yyyymm')=Forms!FormName!ControlName)
Jan 16 '13 #3

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

Similar topics

2
by: JDJones | last post by:
Using PHP and MySQL. Trying to put a list of categories into a drop down select option of a form like: <form name="form" action="<? print $_SERVER?>" method="get"> <select name="subject">...
1
by: Matthew | last post by:
Hey, I have built a form that has certain combo and text boxes on it, which a user specifies his criteria and then clicks on a search button to run a query based on that criteria. To build to...
3
by: Stijn Vanroye | last post by:
Hi List, I'm running a query on a not-so-small db. Mostly this query runs fast enough, but every once in a while the query takes a long time to complete in wich case the users start banging away...
1
by: Kevin.S.Campbell | last post by:
Greetings, I'm trying to run a sql query on a continous form. I have the query working correctly the way I want it. I want this query to be displayed on the form in the text box on the load...
2
by: amith.srinivas | last post by:
Hi all, From a word macro in VBA, I am trying to create a report in access DB. The report is based on a query with a parameter. I am using Set rpt = Application.CreateReport rpt.RecordSource =...
5
by: Ferasse | last post by:
Hi, I'm an occasional Ms-Access developer, so there is still a lot of stuff that I don't get... Right now, I'm working on a database that stores contractual information. One of the form that...
2
by: scolivas | last post by:
I would like to make a form that creates a query. I know that I could make a query for each radio button instance but that would take forever! So basically what i have is 10 Fields in a query ...
6
gnawoncents
by: gnawoncents | last post by:
I have a form (FRMsurveyReports) with several combo boxes (e.g. Class, ClassUnique, SurveyID, etc.) which use an SQL query based on a table (TBLSurveyResponses) for their record source. The...
1
by: Karen D | last post by:
Help Again!! I’m using Access 2003 and I have a form that allows users to enter criteria for selecting tables and queries as well as the query parameters that will be used to generate a report. The...
1
Fspinelli
by: Fspinelli | last post by:
Hi, I have to run a query based on check boxes that are checked. Only those records with a specific check box (or boxes) should come up. I created a form off of that query using those check...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.