Counting checkboxes between two dates

I'm tring to build a query that will count the number of checkboxes between
the dates of two other fields. I have two tables within the query. One table
(tblInspection) contains InspectionID, InspectionDate, and Citation, among
others. The other table (tblReinspection) contains ReinspectionID, and
ReinspectionDate, among others. There is a one to many relationship between
the two tables, tblInspection being the parent table. Only one InspectionDate
will be entered but none or many ReinspectionDates may be entered. The
Citation field is a checkbox.

What I am tring to do is to find all the records that have date entries
between two dates (inspection or reinspection dates) and then count all of
the records with checkmarks in the citation field. The problem is that
several records for the same inspection because there may be several
reinspection dates. When I try to count the checkmarks it counts one for each
record. I need it to count one for each inspection.

This is where I started.

SELECT tblInspections.InspectionDate, tblReinspections.ReinspectionDate,
tblInspections.Citation
FROM tblInspections INNER JOIN tblReinspections ON tblInspections.
InspectionID = tblReinspections.InspectionID;

Thanks for the help.

-- 
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/200707/1

0
ThomasK
7/10/2007 2:51:42 PM
access.queries 6343 articles. 1 followers. Follow

2 Replies
674 Views

Similar Articles

[PageSpeed] 21

Hi ThomasK

if I understood,  try it
----
SELECT tblInspections.InspectionDate, tblReinspections.ReinspectionDate,
tblInspections.Citation,tblInspections1.CountOfCitation
FROM
(( SELECT
  InspectionDate,
 Count(Citation) AS CountOfCitation
 FROM tblInspections
 WHERE tblInspections.Citation=True
 GROUP BY InspectionDate
 ) AS tblInspections1
INNER JOIN tblInspections ON
tblInspections1.InspectionDate=tblInspections.InspectionDate)
INNER JOIN tblReinspections ON tblInspections.InspectionID =
tblReinspections.InspectionID
WHERE tblInspections.Citation=True
   AND   tblReinspections.ReinspectionDate Between #01/01/2007# AND
#01/31/2007#
----

you can also make a query with the derived table
qryInspections1
----
SELECT
  InspectionDate,
 Count(Citation) AS CountOfCitation
 FROM tblInspections
 WHERE tblInspections.Citation=True
 GROUP BY InspectionDate
---

then use it in principal query
----
SELECT tblInspections.InspectionDate, tblReinspections.ReinspectionDate,
tblInspections.Citation,qryInspections1.CountOfCitation
FROM (qryInspections1
INNER JOIN tblInspections ON
qryInspections1.InspectionDate=tblInspections.InspectionDate)
INNER JOIN tblReinspections ON tblInspections.InspectionID =
tblReinspections.InspectionID
WHERE tblInspections.Citation=True
   AND   tblReinspections.ReinspectionDate Between #01/01/2007# AND
#01/31/2007#
----

bye
-- 
Giorgio Rancati
[Office Access MVP]

"ThomasK via AccessMonster.com" <u16264@uwe> ha scritto nel messaggio
news:74f7c07af2c8f@uwe...
> I'm tring to build a query that will count the number of checkboxes
between
> the dates of two other fields. I have two tables within the query. One
table
> (tblInspection) contains InspectionID, InspectionDate, and Citation, among
> others. The other table (tblReinspection) contains ReinspectionID, and
> ReinspectionDate, among others. There is a one to many relationship
between
> the two tables, tblInspection being the parent table. Only one
InspectionDate
> will be entered but none or many ReinspectionDates may be entered. The
> Citation field is a checkbox.
>
> What I am tring to do is to find all the records that have date entries
> between two dates (inspection or reinspection dates) and then count all of
> the records with checkmarks in the citation field. The problem is that
> several records for the same inspection because there may be several
> reinspection dates. When I try to count the checkmarks it counts one for
each
> record. I need it to count one for each inspection.
>
> This is where I started.
>
> SELECT tblInspections.InspectionDate, tblReinspections.ReinspectionDate,
> tblInspections.Citation
> FROM tblInspections INNER JOIN tblReinspections ON tblInspections.
> InspectionID = tblReinspections.InspectionID;
>
> Thanks for the help.
>
> -- 
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/200707/1
>


0
giorgio
7/10/2007 4:12:35 PM
Thanks for your help. 
The problem Im having with your responce is that I have only made queries in
design view. So I'm having a little trouble understanding. So, the solution
involves a query quering the results of another query?

Tom

-- 
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/200707/1

0
ThomasK
7/11/2007 2:29:02 PM
Reply:

Similar Artilces:

Date #9
One column has the date which I enter manually. If I type 15may it converts immediately to 15-May which is great. But how can I get the line to enter dates automatically? What I need is to enter one date (say, 20 May) and for all lines below to automatically add 1 day at a time, either at the time of starting the line, or even before in one go. Thank you very much JB You can use a formula, if you add the date in A2, in A3 put =IF(A2="","",A2+1) copy down as long as needed and format the cells the same way as in A2 -- Regards, Peo Sjoblom "JB"...

Displaying Counts when Filtering
Usually when using the filter function, the total records in the spreadsheet and the number of records that match the filter criteria are displayed on the lower left of the window (I guess it's the status bar). However, for certain files that I have, no counts are displayed when I filter. Does anyone know if there is a setting in the file that causes this or something else that needs to be changed? I do notice this happens frequently with files created by exporting from Access, but not always. It also happens with other files, but I can't find a common denominator. Hi To...

Date and Time
Is it possible to have a cell show the current date and time without entering it, like in word? Nick If you want the current date and time, updated whenever a calculation occurs, use =NOW(). If you want to enter the current date, without updating, press CTRL+; -- Cordially, Chip Pearson Microsoft MVP - Excel www.cpearson.com chip@cpearson.com "Lord Of The Morning" <Not@aol.com> wrote in message news:vmjpgijrjvs5c5@corp.supernews.com... > Is it possible to have a cell show the current date and time without > entering it, like in word? > > Nick > >...

Date Problem !!
hi there i have a big problem with the dates. i enter 09/10/2005 in a cell and it changes to 10/09/2005 !! big problem. it shows 10/09/2005 in the cell but 09/10/2005 in the formula bar !! 2 different dates very confusing is there a way of telling it to use just one kind ??? thanks -- cassy01 ------------------------------------------------------------------------ cassy01's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=780 View this thread: http://www.excelforum.com/showthread.php?threadid=473175 It's the same date, it's just formatted differently o...

Grouping dates in pivot table
I am pulling data from a SQL Server database to create a pivot table. Excel (07) is not recognizing the field as a date. This is a field I would like to group by in the pivottable. I am aware of all the techniques to convert this to a date field, but I am searching for an answer as to why XL pivot tables cannot consume the dates directly from a sql query. I have played with bringing the dates back in a number of differenent formats with no success. Any insights into this would be appreciated. Probably coming in as text and yuo may only need to copy an unused cell and paste sp...

Question about Date validation
Hi All, I'm working on a form for weekly data entry. I'd like to create a date field where the user will enter the date the week ends (ie week ending Friday, June 25th). Is there a way to write code so that Access will check that the day the user inputs is a Friday (and if not they will recieve an error message)?. I know how to program the error message pop-up box, but I have no idea how to write code to check if the date inputted is a Friday. Any help would be greatly appreciated! Thanks Use the WeekDay function If WeekDay(Me.DateField) = 6 Then MsgBox "Error" En...

how do i change dates on my calendar and keep my pics
Publisher doesn't support this. You would need to do it manually. -- Brian Kvalheim Microsoft Publisher MVP http://www.publishermvps.com ~pay it forward~ This posting is provided "AS IS" with no warranties, and confers no rights. "Bob T" <Bob T@discussions.microsoft.com> wrote in message news:68671977-F71B-444F-AE72-801D2B359FEE@microsoft.com... > ...

SUMIF with two conditions ? #2
I have 3 colums colum A G7705 colum B 300 colum C Units I need sum the units in colum C if colum A & B = "G77053000" Can somone Help =SUMPRODUCT(--(A1:A10="G7705"),--(B1:B10=300),C1:C10) Regards, Peo Sjoblom "Mestrella31" wrote: > I have 3 colums > > colum A G7705 > colum B 300 > colum C Units > > I need sum the units in colum C if colum A & B = "G77053000" > > Can somone Help Ok I did that & it worked, now when I try to get the data from another worksheet it gives me wrong data, do you know why? ...

Hiding tasks with due dates in the distant future
I'd like to display only my tasks for the next month or so. How can I filter out those that are in the distant future or recurring tasks that won't be due until next year or the year after? Hi, Goto the Tasks folder. Goto the Customize current view. Click on the Filter Button. Goto the Advanced Tab. Under define more criteria, clickon the Feilds and then select All Task Feilds and then select Due Date. Then under the condition Select Between and then in the Value enter the range of dates ( say 3/8/2004 and 3/10/2004 ). Hope this helps !!! With Regards, Sudharson.AN "Ambe...

Validate almost one of two textbox
Hi, how can I validate a group of 2 textbox so the users have to populate at least one of them (or both)? Thanks in advance. Luis On Nov 27, 2:16=A0pm, Luigi <Lu...@discussions.microsoft.com> wrote: > Hi, > how can I validate a group of 2 textbox so the users have to populate at > least one of them (or both)? > > Thanks in advance. > > Luis Use Javascript Function function jsValidateTextBoxGroup(sTxtBox1, sTxtBox2) { var bSuccess =3D true; var sTxtBox1Value =3D document.getElementById(sTxtBox1).value; var sTxtBox2Value =3D document.g...

dates
Hi there - I am a new user, have only started using excel 2 days ago but am really enjoying it. I have managed to create timesheets that automatically calculate the time spent on a project. Anyway, enjoying it very much. So, I have dates running down the left hand column (A), eg, 05.10.05. Currently I am inputting these by hand because if I drag that cell down it creates 05.10.06, 05.10.07 etc. I have messed with the 'custom' setting and changed it to 'dd.mm.yy' but this has not solved it. Any help much appreciated. By the way, it's excel 2001 for mac. Tom -- small ...

Count of Unique Items?
Hi, I have a worksheet (Sheet1) where column A consists of dates (in date order). I need to look at this column from another sheet (Sheet2) in the same workbook and return the number of unique dates in this column. For example, on Sheet1 cell A1 has the heading Date, A2 is 10/01/04, A3 is 10/01/04, A4 is 10/01/04 and A5 is 10/05/04. From cell A1 on Sheet2 I need to look at the range A2:A5 on Sheet1 and return the number 2 (the number of unique dates in the range). Any help would be greatly appreciated. Monte Sliger Try the following... =SUM(IF(Sheet1!A2:A5<>"",1/COUN...

How do I look at two worksheets in one Excel workbook at same time
I know how to arrange windows to look at multiple workbooks. But I want to have two worksheets displayed at the same time from the same workbook. Is there a way to do that? Window - New Window this will create a second view of active workbook. Then you can do Window - Arrange, active workbook only. -- Best Regards, Luke M "PeoriaJean" <PeoriaJean@discussions.microsoft.com> wrote in message news:503A1BB9-2130-4346-A0AF-A461388397B2@microsoft.com... >I know how to arrange windows to look at multiple workbooks. But I want to > have two worksheets di...

Historical Stock Status As of Date
This is a multi-part message in MIME format. ------=_NextPart_000_00A5_01C8845C.ADFC9B50 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello, I'd like to know whether anyone has encountered an issue wherein the As = of Date that is printed in the Historical Stock Status Detailed by Item = does not follow the date as indicated in the report options screen. = Currently we are trying to print the said report but no matter what date = we put in, the As of Date that prints on the report is set to 30 Jan = 2008. Is there anything that we...

Find the number of years between two dates
I have aroster of players with thier date of births. I would like to automatically add their ages in another column Try this Formula, assuming that the dob is in cell A1 =DATEDIF(A1,NOW(),"y") & " years, " & DATEDIF(A1,NOW(),"ym") & " months, " & DATEDIF(A1,NOW(),"md") & " days" regards Mukesh "duke" wrote: > I have aroster of players with thier date of births. I would like to > automatically add their ages in another column On Fri, 9 Sep 2005 19:47:02 -0700, "duke" <duke@disc...

How can i use a command button to validate date and time
I have two command buttons, each on a different sheet. i need both of them to put the current date in one cell on its sheet and current time in another on its sheet. i also need these cells to be locked so the user can only edit these cells by clicking the command button. Any answers? ...

Todays Date that does not update
I created a macro and a button that when clicked it entered todays date in a cell, which is what I wanted. I used "Today( )". Problem is the date keeps updating to todays date and I want it to stay the date I entered it in. Is there some other value or formula to do this so it does not update everyday? Thanks!! You need to enter the date itself. Any function will always update to the current date. Ctrl+; will enter the current date in a cell. In VBA, use Range("A1").Value = Date -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC...

DATE 01-04-08
Hello again! I am using this code =DateSerial(Year([Opened Date]),Month([Opened Date]),Day([Opened Date])+10) on my form....is there a way for the date to get recorded in the main table as well. because on the form and the report it shows up, but not in my main table...do I need to run an update querie or something??? Any suggestions?? Thanks Ransom Ransom, It would be simpler like this: =[Opened Date]+10 Is Opened Date a field in the same record as where you want to record this calculated date value in the table. So this date, whatever it is, will always be 10 days after the Ope...

counting seconds
=SECOND(NOW()) and holding down the F9 key starts at whatever the second hand is pointing at and counts up to 59, then starts back at 0, 1, 2, to 59, 0, 1, 2 and so on. How can I write it so it starts at 0, and counts 1, 2, 3,...,59, 60,61,...forever? Hi have a look at http://www.mvps.org/dmcritchie/excel/datetime.htm (at the bottom of this site): There are some example counters / stop timer functions. This may what you're looking for -- Regards Frank Kabel Frankfurt, Germany "scott" <anonymous@discussions.microsoft.com> schrieb im Newsbeitrag news:143e601c3f7f9$b63ac...

date confusion
hi im new to excel 2007 i want to ask that when i type 7/4 in a cell excel thinks that the slash is division operator so it divides it ?? but in different cell it interpret it as date ok another problem is that when I enter 7/4 in the different cell excel interpret it as 4-Jul only but How do I display the year too ? even if i type 7/4/2008 or 7/4/08 it still shows 4-JUL ? Help please thank you very much Format the cell as m/d/yyyy, you created the d-mmm format by just entering 7/4 so you need to reformat the cell to the date format you want. Always use the full date when entering dat...

Count with two criteria
I am working in Excel 2003, I am trying to count with two criteria and multiple sheets. I am using this formula: =SUMPRODUCT(('Sum 1Q10'!A2:A4="BKD")*('Sum 1Q10'!F2:F4="Open")) my result is 0. It should be 1. Is there another way to do this? I really need help. Lisak- There are a couple of approaches to do this; I'll give you the one I use out of habit. The sumproduct conditions evaluate to true or false. You have to force them back to a numeric format. Some folks do that with a leading double negative on each condition. I tend to ...

Money using wrong date to calculate ROI YTD
I have opened a new file in Money to track investments for a stock club. I entered all transactions, which go back to Jan. 2002. When I look at performance for the account, the ROI YTD is not accurate, as Money is using values for the stocks going back only 6 months form the date I enterd the transactions rather than the values as of 1/1/03. What to do? In microsoft.public.money, Brooks wrote: >I have opened a new file in Money to track investments for >a stock club. I entered all transactions, which go back >to Jan. 2002. When I look at performance for the account, &g...

date Format #28
-- Regards, ------------------------------------------------- Mahmoud Metwally Ali Jaicorp IT Manager Office Tel. : (202) 3471495/361 Mob. : (2010) 5195169 ...

How to fill cell with two combobox values?
I am looking for VB code for command button that fills two combo box values and a toggle value (Y/N) behind each other in one cell. Bart Excel 2003 ...

How to reduce thickness/width of window borders two "normal" 2 pixels?
On a certain WinXP all borders of all windows are very, very thick/width. Have a look at the following snapshot: http://img15.imageshack.us/img15/9364/capture20091215121445.png What is the reason resp. how can I reduce it to the "normal" size of (approx. 2 pixels) ? Camille Camille Petersen wrote: > On a certain WinXP all borders of all windows are very, very thick/width. > > Have a look at the following snapshot: > > http://img15.imageshack.us/img15/9364/capture20091215121445.png > > What is the reason resp. how can I reduce it to the &...