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

Fiscal Year

Hi!

I wanted to modify the query the query is given below.

SELECT Format([OpDate],"yyyy") AS [Year], ProcFees.ProcName, Count(ProcFees.ProcName) AS CountOfProcName
FROM ProcFees INNER JOIN (Procedures INNER JOIN ProcDetails ON Procedures.[Order ID] = ProcDetails.[Order ID]) ON ProcFees.[Proc ID] = ProcDetails.[Proc ID]
WHERE ProcFees.ProcName<>"General Anaesthetic" And ProcFees.ProcName<>"Local Anaesthetic"
GROUP BY Format([OpDate],"yyyy"), ProcFees.ProcName
HAVING ((Format([OpDate],"yyyy")<>"IsNull") And (ProcFees.ProcName<>"IsNull"));

The above query generates following results:

Year Procedure Year Total
2000 Abdominoplasty 4
2000 Bilat Pinnaplasty 3
2001 Abdominoplasty 1

I actually gives the procedure and its total for the year starting at 1st January and ending at 31st December.i want to edit the query so it may provide me results starting at 1st Apr and ending at 31st March. i.e for year 2006 should now start at 1st Apr 2006 and end at 31st March 2007 and for year 2007 i would start at 1st Apr 2007 and end at 31st March 2008.

I am unable to create any such query.
Could anyone help me out please. It would be really apreciated if you could give me the exact query for the solution.

Thanking in Advance.
Uzair
Jun 27 '07 #1
7 1677
MMcCarthy
14,534 Expert Mod 8TB
You can't do this with a simple query. You could work out the criteria to return the data for one fiscal period but not to group the data by that fiscal period.

You will need to introduce a new column to the table for the FiscalYear with a value something like "2006/2007"

Then create a update query like the following to populate the column.

Expand|Select|Wrap|Line Numbers
  1. Update TableName SET FiscalYear = IIf(Month([OpDate])>3, """ & Year([OpDate]) & "/" & Year([OpDate])+1 & """, """ & Year([OpDate])-1 & "/" & Year([OpDate]) & """
  2.  
Once you have done that you can now run the query as follows:
Expand|Select|Wrap|Line Numbers
  1. SELECT ProcFees.FiscalYear, ProcFees.ProcName, Count(ProcFees.ProcName) AS CountOfProcName
  2. FROM ProcFees INNER JOIN (Procedures INNER JOIN ProcDetails ON Procedures.[Order ID] = ProcDetails.[Order ID]) ON ProcFees.[Proc ID] = ProcDetails.[Proc ID]
  3. WHERE ProcFees.ProcName<>"General Anaesthetic" And ProcFees.ProcName<>"Local Anaesthetic"
  4. GROUP BY ProcFees.FiscalYear, ProcFees.ProcName
  5. HAVING ((Format([OpDate],"yyyy")<>"IsNull") And (ProcFees.ProcName<>"IsNull"));
  6.  
I haven't touched the Having part as I'm not sure what if anything it is doing.
Jun 29 '07 #2
Thanks for u'r intrest.

I am real novice to Access so could you please tell me how would i be able to run the below sql you mentioned

UPDATE Procedures SET FiscalYear = IIf(Month([OpDate])>3, """ & Year([OpDate]) & "/" & Year([OpDate])+1 & """, """ & Year([OpDate])-1 & "/" & Year([OpDate]) & """);

What i have done to run this query was i added a column named FiscalYear in the Procedures database and gave its datatype to Date/Time but following message is shown:

"Procedure didn't update 61 Fields due to type conversion failure, 0 records due to key violation,......."

What should be the data type of Fiscal Year?

And when ever a new procedure would be added, fiscal year would be auto populated or i have to run the above mentioned query again.

I really appreciate the help you have provided.

Thanking in Advance,
Uzair.
Jun 29 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
Thanks for u'r intrest.

I am real novice to Access so could you please tell me how would i be able to run the below sql you mentioned

UPDATE Procedures SET FiscalYear = IIf(Month([OpDate])>3, """ & Year([OpDate]) & "/" & Year([OpDate])+1 & """, """ & Year([OpDate])-1 & "/" & Year([OpDate]) & """);

What i have done to run this query was i added a column named FiscalYear in the Procedures database and gave its datatype to Date/Time but following message is shown:

"Procedure didn't update 61 Fields due to type conversion failure, 0 records due to key violation,......."

What should be the data type of Fiscal Year?

And when ever a new procedure would be added, fiscal year would be auto populated or i have to run the above mentioned query again.

I really appreciate the help you have provided.

Thanking in Advance,
Uzair.
The datatype should just be text. You will need to set up a procedure to add the Fiscal Year to new records.

Once we get the query sorted you can tell me how the records are being added. Presumably you are using a form.
Jun 29 '07 #4
Thanks a lot i figured it out. I kept FiscalYear's DataType as Text and my problem is solved Thank You so much.
Jun 29 '07 #5
weel the input is through form where the record for Procedures is added.
And i entered the update sql as Queries not as procedure.

What would be the method of running this query. Should i ammend it with insertproc query if so show should it be ammended.

regards,
Uzair
Jun 29 '07 #6
MMcCarthy
14,534 Expert Mod 8TB
weel the input is through form where the record for Procedures is added.
And i entered the update sql as Queries not as procedure.

What would be the method of running this query. Should i ammend it with insertproc query if so show should it be ammended.

regards,
Uzair
The update query was just a one off to amend your existing records.

On the form you use to add new procedures. In design view you need to drag the FiscalYear Field on to the form from the Field list.

Then go to the control for the OpDate field and create an After Update event as follows:

Expand|Select|Wrap|Line Numbers
  1. Private Sub OpDate_AfterUpdate()
  2.     If Month(Me.OpDate) > 3 Then
  3.         Me.FiscalYear = """ & Year(Me.OpDate) & "/" & Year(Me.OpDate)+1 & """
  4.     Else
  5.         Me.FiscalYear = """ & Year(Me.OpDate)-1 & "/" & Year(Me.OpDate) & """
  6.     End If
  7. End Sub
  8.  
Jun 29 '07 #7
FishVal
2,653 Expert 2GB
Hi!

I wanted to modify the query the query is given below.

SELECT Format([OpDate],"yyyy") AS [Year], ProcFees.ProcName, Count(ProcFees.ProcName) AS CountOfProcName
FROM ProcFees INNER JOIN (Procedures INNER JOIN ProcDetails ON Procedures.[Order ID] = ProcDetails.[Order ID]) ON ProcFees.[Proc ID] = ProcDetails.[Proc ID]
WHERE ProcFees.ProcName<>"General Anaesthetic" And ProcFees.ProcName<>"Local Anaesthetic"
GROUP BY Format([OpDate],"yyyy"), ProcFees.ProcName
HAVING ((Format([OpDate],"yyyy")<>"IsNull") And (ProcFees.ProcName<>"IsNull"));

The above query generates following results:

Year Procedure Year Total
2000 Abdominoplasty 4
2000 Bilat Pinnaplasty 3
2001 Abdominoplasty 1

I actually gives the procedure and its total for the year starting at 1st January and ending at 31st December.i want to edit the query so it may provide me results starting at 1st Apr and ending at 31st March. i.e for year 2006 should now start at 1st Apr 2006 and end at 31st March 2007 and for year 2007 i would start at 1st Apr 2007 and end at 31st March 2008.

I am unable to create any such query.
Could anyone help me out please. It would be really apreciated if you could give me the exact query for the solution.

Thanking in Advance.
Uzair
Hi!

The following expression will return fiscal year of [OpDate] whish starts at 1st Apr. -3 is the number of last month in fiscal year with "-" sign.

Year(DateAdd("m", -3, [OpDate]))

Good luck.
Jun 29 '07 #8

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

Similar topics

1
by: MissiMaths | last post by:
This isn't really an access question as I can write the code myself(I hope) but need to know how the start of the financial year is worked out. If someone knows the rules or an algorithm, I would...
3
by: haydn_llewellyn | last post by:
Hi, My company runs on a fiscal calendar that starts on the first monday in July, and is based on a 13 week quarter (4 weeks, 4 weeks, 5 weeks). What I need, is a way of relating Date() to the...
2
by: JohnC | last post by:
This fantastic expression was posted by Duane Hookom. I have no idea how it works but it displays the fiscal year and quarter for FY starting on October 1. =Format$(DateAdd("q",1,),"\Qq...
1
by: rkohon | last post by:
Hello all, I am new to JavaScript and need some ideas, suggestions, or code snippets. I have a form which requires the end user to put in a date for required items. I need javascript function to...
4
by: Twobridge | last post by:
Hi I am trying to perform a search that will return records based on a fiscal year search of the bill_Date. The user gives the year then I want to search based on the fiscal year (July 1 - June...
2
by: Sund via AccessMonster.com | last post by:
I do fair amount of data analysis using access pivot tables and charts. Can any body suggest a method to run the queries based on accounting month and Accounting year.As an example: I want to...
4
by: ltazz | last post by:
How can i make it so that Access will Recognize the fiscal year 07 start at 1 oct 2006, and end 30 Sep 2007? i know its possible, however cant figure it out. Thanks for the help in advance you...
3
by: shiznaw | last post by:
I got another problem while working on this database for the Univ. The Form.viewreports has several radial button options so that the user can view a Report for several periods--like a day, a...
6
craigfr
by: craigfr | last post by:
I am making a graph comparing last year's defect data with YTD defect data. Our fiscal year starts Nov.1 and ends Oct.31. To get the YTD, I started used a simple date serial criteria: Between...
2
by: RZ15 | last post by:
Hi guys, I'm really drawing a blank here for how to deal with fiscal months in my monthly sales/receipts reports. My issue is that calculating the months is not as simple as saying 'if the invoice...
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: 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
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...
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.