473,387 Members | 1,606 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,387 software developers and data experts.

How do i count a total of a value using a From and to date.

Help Please, (Access 2003)

I have made the expression for my count which i have done successfully (as you can see on my screenshots), but i would like to use a from and to date as we would run this query on a weekly basis.

The idea is to know how many enquiries each of our lawyers have had each week.

Is this possible?
If so could someone help me with the expression please.

Regards
Kyle




Attached Images
File Type: jpg Screen Shot 05-07-15 at 11.49 AM.jpg (3.5 KB, 228 views)
File Type: jpg Screen Shot 05-07-15 at 11.53 AM.jpg (16.4 KB, 351 views)
May 7 '15 #1

✓ answered by Seth Schrock

You would use the Between statement on your date field. For example
Expand|Select|Wrap|Line Numbers
  1. Between #5/1/2015# And #5/7/2015#
You can also replace the explicit dates with references to controls on a form.

18 1781
Seth Schrock
2,965 Expert 2GB
You would use the Between statement on your date field. For example
Expand|Select|Wrap|Line Numbers
  1. Between #5/1/2015# And #5/7/2015#
You can also replace the explicit dates with references to controls on a form.
May 7 '15 #2
Thank you,

would it only pick up the date if it was on the table i was doing the query on.

Bearing in mind i have set up the relationships on my tables.
May 7 '15 #3
Seth Schrock
2,965 Expert 2GB
As long as the table that has the Date field is included in the query, then you can use it in the criteria.
May 7 '15 #4
Oh right okay i got it now, thank you for your help its much appreciated.
May 7 '15 #5
Hi,

Sorry to bother you again, i have tried the expression but i keep getting this error:

"The expression you entered contains invalid syntax"
"You may have entered a comma without a preceding value or identifier"
May 7 '15 #6
Seth Schrock
2,965 Expert 2GB
Please post the SQL for your query (inside CODE tags) so that I can look at it.
May 7 '15 #7
Expand|Select|Wrap|Line Numbers
  1. SELECT Count("AH") AS [F/E]
  2.    ,Between #2/20/2015# And #2/24/2015# 
  3.       AS Expr1
  4. FROM [Conveyancing Enquiries] 
  5.    INNER JOIN [Conveyancing F/E Totals] 
  6.       ON [Conveyancing Enquiries].ID 
  7.          = [Conveyancing F/E Totals].ID;
It would not let me exit becuase of this error so i have had to take out Between, thats seems to work but i get -1 as the result and this definately isn't accurate.
May 7 '15 #8
Seth Schrock
2,965 Expert 2GB
The Between statement goes in the WHERE clause and it needs to know what field it is checking. For example, if your date field is called EnquiryDate, your query would look like this:
Expand|Select|Wrap|Line Numbers
  1. SELECT Count("AH") As [F/E]
  2. FROM [Conveyancing Enquiries] INNER JOIN [Conveyancing F/E Totals] ON [Conveyancing Enquiries].ID = [Conveyancing F/E Totals].ID
  3. WHERE EnquiryDate Between #2/20/2015# And #2/24/2015#
May 7 '15 #9
It now looks like this, is this correct?
Expand|Select|Wrap|Line Numbers
  1. SELECT Count("AH") AS [F/E]
  2. FROM [Conveyancing Enquiries] 
  3.    INNER JOIN [Conveyancing F/E Totals] 
  4.       ON [Conveyancing Enquiries].ID
  5.          =[Conveyancing F/E Totals].ID
  6. WHERE ((([Conveyancing Enquiries].Date) 
  7.    Between #2/20/2015# And #2/24/2015#));
May 7 '15 #10
I have ran the query and it does now seem to be pulling through the information i need, i am just going to try a different date just to confirm.
May 7 '15 #11
Yes all seems okay now once again thank you for your help.

Sorry for being a pain :)
May 7 '15 #12
Seth Schrock
2,965 Expert 2GB
This is how we all learn :)
May 7 '15 #13
zmbd
5,501 Expert Mod 4TB
You might want to update your SQL to use parameters instead of having to hard code this all of the time:

Use parameters in queries and reports

and a slightly different viewpoint:
How to use the query by form (QBF) technique in Microsoft Access

and the always useful Allen Browne:
Limiting a Report to a Date Range

and here's a generic example based on a query I run in-house using the form...
Expand|Select|Wrap|Line Numbers
  1. SELECT TestDate
  2.    , ReadDate, Resample
  3.    , Passing, TestingResult1
  4.    , LotNo
  5. FROM tableA
  6. WHERE (((ReadDate) 
  7.    Between 
  8.       [Forms]![Form_PullDates]![Text_Start] 
  9.    And 
  10.       [Forms]![Form_PullDates]![Text_End]))
  11. ORDER BY TestDate;
The form has logic behind it to check for proper date format, that start is an older date than end that they two dates are not the same etc...
May 11 '15 #14
Hi,

I have tried running the expression to count a particular value from a field (F/E Field) i want to calculate how many times a certain F/E has been entered but when i run the expression

Count ("PM")

It just counts how many records are in the table altogether rather than just one individual, is it the expression i am entering wrong or just the way the tables are set up.

Regards
Kyle
May 13 '15 #15
zmbd
5,501 Expert Mod 4TB
well Count("PM") is only counting the field named PM not specified entries. That would require a conditional clause.
generic example:
Expand|Select|Wrap|Line Numbers
  1. SELECT tbl_people.people_sex
  2.    , Count(tbl_people.people_sex) 
  3.       AS CountOfpeople_sex
  4. FROM tbl_people
  5. GROUP BY tbl_people.people_sex
  6. HAVING (((tbl_people.people_sex)="f"));
  7.  


Would you post your SQL again?
May 13 '15 #16
Expand|Select|Wrap|Line Numbers
  1. SELECT Count("PM") 
  2.    AS [F/E]
  3. FROM [Personal Injury Enquiries];
  4.  
May 13 '15 #17
zmbd
5,501 Expert Mod 4TB
1) Does this give you any help:
Expand|Select|Wrap|Line Numbers
  1. SELECT Count("People_sex") 
  2.    AS Wonder
  3. FROM tbl_people
  4. WHERE (((people_sex)="f"));
  5.  
2) It is best practice when naming fields, tables, and files to avoid the use of anything other than alphanumeric characters and the underscore (spaces although allowed are problematic from a programing point of view and best avoided) and it is VERY important to avoid all reserved words and tokens:
Access 2007 reserved words and symbols
AllenBrowne- Problem names and reserved words in Access
May 13 '15 #18
Hi All,

Thanks for all your help but i did eventually find what i was looking for.

this seems to work and provide me with the info i need.

Expand|Select|Wrap|Line Numbers
  1. PARAMETERS [Month Number] Text ( 255 ), [Search Text] Text ( 255 );
  2. SELECT [Personal Injury Enquiries].[F/E], [Personal Injury Enquiries].Date
  3. FROM [Personal Injury Enquiries]
  4. WHERE ((([Personal Injury Enquiries].[F/E]) Like "*" & [Search Text] & "*") AND (([Personal Injury Enquiries].Date) Like "*" & [Month Number] & "*"));
May 26 '15 #19

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

Similar topics

4
by: ZyPhiX | last post by:
Hi, I've got a little problem: I'm trying to make a webpage with a few scrolldown menu's and I want to count the values of them. In the scrolldown menu's are no numeric values but the have to...
1
by: David Lozzi | last post by:
Howdy, I am trying to accomplish the following: dim DateSend as date if txtDateSend.text = "" then DateSend = dbnull.value else DateSend = txtDateSend.text
3
by: Liam Mac | last post by:
Hi All, Can anyone direct me or provide advice on how I can assign a null value to a date variable in vb.net. Basically what I'm doing is that I'm looping through a recordset where I have three...
4
by: scota | last post by:
I am new to ASP.NET, C#. I have the following code which will not display the total Credits for all the records. It is printing "Total Credits: 0" instead of adding the credits. What am I...
2
by: HarisHohkl | last post by:
Hi, I've this function in a class to update the total value.but when i try to remove the these row highlight in Bold it crash, what should i do???? void display_total_value() { double...
1
Stang02GT
by: Stang02GT | last post by:
Here is the issue that I am having. I have two text feilds where users need to enter a "From Date:" and a "To Date:" they then hit a update button and my code will pull back the data for the date...
2
by: alwaali | last post by:
Hi I need help please This is my project and i need a help to solve it with you A page of text is to be read and analyzed to determine number of occurrences and locations of different words. The...
1
by: Kenny24 | last post by:
Hope someone can help with this problem I have! On Access, I have a combination of 10 'true/false' buttons that can be selected. Eg. 10 different types of cake. The user can select any amount...
1
irwansyahazniel
by: irwansyahazniel | last post by:
I want to calculate total value in index , previous value is 0, but I have replaced and display it with the calculation result “1/y”, and when I calculate total value, value that summed is previous...
1
by: shahed1985 | last post by:
I create a MS access database with two table Main_table : ID_number, Student_name, Class Collection_Table : Collection_Date, ID_number, Student_name, Class, PaidForMonth,Installment,...
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: 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...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.