I have a query with a Total Row and I want it to do its thing only on a specified date range. I have no problem getting date ranges to work in the Criteria section for Select Queries but am now trying it on this calculated query and it is not working. Is it possible to filter using Criteria when you are also using the Total Row? See the attached picture for the simple date criteria I am using that is having no effect at all on the results.
I have determined the solution to my problem lies outside of normal SQL queries and I need to create a UDF.
Here is the problem. I need to create a running total based on the sum of two fields [PTS_ISSUED] & [PTS_REDUCED] with one restriction. The total can never be less than 0. If it is less than zero, the totals reset with [PTS_ISSUED] as the new starting point.
I've attached an excel spreadsheet. Column"C" contains the formula logic I am trying to replicate into access.
I will be honest, writing the UDF is beyond my current knowledge but once I see it I am able to understand it and implement it.
I believe the solution needs to store the running total into a variable, make the necessary comparisons and determine if its okay to add the [PTS_ISSUED and [PTS_REDUCED] to the stored total of the previous calculations then advance. I just have no clue in how to go about writing it.
This calculation needs to be presented in Access because the results will drive several other functions within the database.
I have a query I am trying to build currently which creates a running total based on set criteria. I essentially have three columns (All times are in minutes). The visit ID, the duration of a visit and the time difference between the current and previous visit. e.g.
So a line will have the calculation of the current time + the difference between the current and previous visit if the difference is below 20. I have the following:
Code: Public Function Cont20(MyVal As Long, MyDif As Long) As Long Static OldValue As Long Dim NewValue As Long If MyDif >= 20 Then NewValue = MyVal OldValue = 0
[Code]....
Which I put as Cont20([Duration],[Difference])
The problem seems to be on the return aspect, its not calculating correctly. I had the formula in Excel which worked great, but this is proving troublesome. As a note the Excel formula was such that it would add the previous running total and then add the current duration and current diff. e.g. In cell A7 the formula would be A6+B7+C7 and so on.
I am trying to aggregate IIF functions to give me the total in separate columns (fields) according to the criteria applied however I am getting an error message "You tried to execute a query that does not include the specific expression
as part of an aggregate function, and I cannot find why, The query is as follows:
SELECT
Tbl_Advisor_raw.Month, Sum(Tbl_Advisor_raw.ValuePay) AS ValuePay, Sum(Tbl_Advisor_raw.Salary) AS Salary, Sum(Tbl_Advisor_raw.NetRevenue) AS NetRevenue, IIf(ValuePay>0,(ValuePay/Salary),0) AS pcSpend,
I have a very simple query on an accounts form to show a running transaction history.
Identifying from the TransactionID (shown for display purposes only - normally hidden) three or four postings make up one transaction.
Using TransactionID 10 as an example, I'd like to have a sum of total [Credit]-[Debit] and have the query display on one line (either at the top of £1,429, or at the bottom of £16,995) to identify this is in fact one transaction, having three posts.
Transaction 9 will have obviously have one total, as this is a single post.
11 the same as 10, by having one total Transaction Value either at the top of the row or bottom.
Hi All. I try to generate a report which calculate subtotal for patient AMOUNT for current year and total for whole period from first visit to current date. The result of subtotal =Sum(IIf(Year(Date()=[VisitYr]),[Amount])) is the same like total. What is a correct way? Thanks.
I have a simple table named [Groups] containing a Primary key ID, a Group name, a Group Leaders name and a date field. The date field merely lists the date of a particular Group related occurrence.
I need to know how many records have dates entered and assumed a simple total would achieve this. The Total is correctly shown in the appropriate row but most, but not all, of the date records are converted to show the same 'total' number.eg the date 28/01/2014 is changed to !4. Quite a weird occurrence.
Is it the case that date records cannot be totaled, in which case, why not all?
I have a table ("tbl_idq_all") with a text field for product codes ("scode"), a date field (dd/mm/yyyy) and a quantity field ("po_qty"). This table therefore holds future receipts of stock for products.
What I am having trouble doing is create a running total of [po_qty] based on [scode] and [Date].
A good example is stock code 10254. This has a quantity of 40,032 arriving 01/06/2013 and a quantity of 30,096 arriving 01/09/2013.
I have to create a query in access that will calculate two Date and time fields [Date & Time Left]/ [Date Returned], need to figure out between the two fields. Trying to identify when the rep returned the call and the number of business hours (6:00am - 4:30pm) it takes to return a message in Ms Access 2010.
The only issue is the calculation has to be done by time and so I have to calculate what time they left the message(so the difference between [Date & Time Left] and [Date Returned) [Date & Time Left] and when the rep returned the message which is suppose to be [Date Returned] but the problem with this field is the data entry is in date format (10/9/2014, 00/00/0000) of Date and not Date and Time like the [Date & Time Left] field, so I don't know what to do now. Not sure what to do now not a database that create or have allot of control over.
Any way of setting up a table containing the following date/time fields.
StartDate StartTime EndDate EndTime
Ultimately I will need to be able to subtract these date/times to get a total time between the two. Should I combine the start date and times in one cell or keep them separate.
In either scenerio, how do I subtract the two in a query for a report?
I have set up a report which prompts the user for a start and end date. However, if they want to run it for a full month they enter eg. 01/07/07 and 1/07/07 - this will not include entries ending on 31/07/07.
Is there a way I can change the criteria prompt so that it read both dates entered as inclusive in the query. I am currently using Between [enter earliest date:] and [enter latest date:]
I'm creating s simple database to track my printer toner supplies, what i want is that..every time I select a date (using date picker) it will automatically deduct 1 from the total number of toners on stock. Right now, i have to input 1 in a field and it will update the remaining toners.
I am trying to create a query that has a self referencing running total based on the values (point totals) of itself (running total of values in the running total column that have already been calculated for all previous records) plus the total of new points being added in the current record, less the total of points being removed in the current record. This running total can never go below 0, if it does, the running total should restart at zero and add in only new points and begin the process again with the next records
I am able to do this in Excel in less than two seconds so I know there has to be a way to port this into a query. I've attached an excel example of what I am exactly trying to do
If it takes multiple queries to complete the required output I am ok with it. In my previous outtakes I have had up to 8 queries but just couldn't seem to do it..
1) I am pretty newbie to this access programming, do forgive me if my questions sounds stupid.
2) Basically I create an application in access capturing or production information for my company. now the top management suddenly wanted whats their main concern:- Total Daily/Monthly, Quarterly, Annual Sales (By Model If possible)
3) I start with daily (Lets don't be too overly ambitious).
4) I try to let user select dates from my calender control and reflect daily sales (in Total & By Model break down) insert into my form.
5) Understand someone told me from my previous post in Calender control I can achieve it either through forms or queries, which is a better way. (in terms of flexibility to change for program maintenance/ scalibility) wise ?
Hello buddies :D, do you have any idea how to make this work?
To select data that falls within this criteria of date range between cboDate and cboDate2 (fields on my form). The date in [tblJobDetails]![timeIn] come in this format "08/17/06 10:24 AM", but the cboDate/cboDate2 (takes in date only e.g 08/17/06) what i am after is to evaluate specific hard coded time in addition to the date entered, i.e. even tho, i haven't entered time on the cboDate/cboDate2, I want specific time hard coded where e.g If i select a date range of 08/17/06 and 08/18/06 on my cboDate and cboDate2 it should really be evaluating: 08/17/06 8:00 AM to 08/18/06 8:00 AM.
This is the criteria i curentlly have on my query in design view tha works perfect in selecting date only. ([tblJobDetails]![timeIn]>=[Forms]![frmPendingJobs]![cboDate] Or [tblJobDetails]![timeIn]>=[Forms]![frmPendingJobs]![cboDate] Is Null) And ([tblJobDetails]![timeIn]<=[Forms]![frmPendingJobs]![cboDate2] Or [tblJobDetails]![timeIn]<=[Forms]![frmPendingJobs]![cboDate2] Is Null) How can I incorporate 8:00am to 8:00am into my cboDate and cboDate2. What can i do to make this happen? Your kindness will be greatly appreciated http://www.naijaryders.com/forums/images/smilies/thankyou.gif
I have this exercise I am doing for access on a sample database. I have already made a table form etc...there is a field with date in the form.. "1/6/2004" for example. The exercise wants me to set, for example, criteria between two dates. How do I do that? I used >#1/6/2004# AND <#30/6/2004#
for finding etc betweeen 1/6/2004 and 30/6/2004 but it doesnt work...
What is the correct syntax of this kind of expression?
I'm having some trouble developing a query based on a specific date criteria. I have a date field, called "SurgeryDate" with 4 fields next to it, "3Month", "6Month", "9Month", and "12Month", which are auto calculated with a control source of =DateAdd("y",+90,[SurgeryDate]), based on the date entered in "SurgeryDate". What I would like to do is create a query that, when run, will check each of these 4 fields against TODAY's date, and find any that match today's date, or are 2 days after today. My goal is to build a form off this query that will display the records that match this criteria so that they can be updated. I'm not really sure how to approach this issue. I think the problem I may be running into may be related to the fact that these fields are calculated from a different date. Any suggestions? Thanks.
hi guys, I am newbie :) just started learning how to use access a month ago. It may be a simple question to some of you guys, but I am having trouble figuring how to implement this.
So I created a query with a field "AuditDate" I want to audit record every 90 days after "AuditDate". I want like a warning to audit my record after 90days. Maybe Click on something on the form to show a list of record. Do anyone have a simple formula i can use to implement the "auditdate + 90 days"?
I also have a query on other database with a field "TermDate". I want to set a criteria to list all my records 90 days or older from TermDate. Please let me know if theres some simple formula
Hi all, I have a field in my database which shows the last date of review for clients. I have a query from this which shows any reviews which are overdue - they have to be completed every 6 months, so I use
<Date()-180 Or Is Null
The thing is, now we need a query to show clients whose review WILL be overdue in the following month from a date that we enter. e.g, if we enter 1/06/07, we want to see everything that will become overdue in the month of June.
Can anybody help me with the criteria I need to enter in a query to get this result? Thanks for any help :) elsiegee
Can anyone see a problem with this criteria in my query? SELECT Orders.[Date requested], Orders.[Item ordered], Orders.[Quantity ordered] FROM Orders WHERE (((Orders.[Date requested])>Date()-10)) ORDER BY Orders.[Date requested] DESC; I get and "Undefined function 'Date' in expression." message. I don't get it! :)
I need to create a query that only shows items that have a completion date of less than 7 days from the last completion date. i have inspections on vehicle that are due every 7 days but i have noway to tell without going through every one and would like to find out if there is a way to set up a query that takes the difference for the last two entries on on each license plate and if the diffrence is greater than seven then it will show me its last two dates of completion and nothing more.