Solved

Quarters and Total days calculations not working correctly on a Form/Query

Posted on 2013-01-23
4
394 Views
Last Modified: 2013-01-23
I have a table that I created from a Query out of SQL.

tblFiscalQuarters_2
The Data looks where my data like similar to this:
FStart       FEnd              Year              FYear      FQ      Days       Vacation       Weekends      Total
1/1/2012       2/29/2012      2012      FY2012      FQ3      60              2                 17                 41
3/1/2012       5/31/2012      2012      FY2012      FQ4      92              1                 26                 64
6/1/2012       8/31/2012      2012      FY2013      FQ1      92              1                 26                 64
9/1/2012      11/30/2012      2012      FY2013      FQ2      91              3                 26                 62
----------------------------------------------------------------------------------------------------------------------------------------
SECOND TABLE:
Copy Of tblProjects1
ProjectID
Project
FStartQ
FEndQ
Days
-----------------------------------------------------------------------------------------------------------------------------------------
On my form in Access I will select:
ProjectID
Project
FStartQ:
FYear (ComboBox pulling from tblFiscalQuarts), then FQ (populated by VB Code) , then Days (populated by VB Code).
FEndQ:
FYear (ComboBox pulling from tblFiscalQuarts), then FQ (populated by VB Code) , then Days (populated by VB Code).
of days(populated by VB Code).
Both Days fields total (VB Script) and are stored the main table.

DAYS:
Days need to automatically sum (FEndQ.Days + FStartQ.Days) and store in main table.
-------------------------------------------------------------------------------------------------------------------------
 
However if my users choose FY2013, FQ1 and FY2014 FQ1, it is not totaling all the days in the range.
Plus my VB Code is concatenating the numbers and not subtracting them.


I attached the DB to make it easier to understand what I am doing.
Database1.mdb
0
Comment
Question by:gracie1972
  • 2
  • 2
4 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 38811960
use this codes


Private Sub QEnd_AfterUpdate()
Me.QEndDays.Value = Me.QEnd.Column(2)
Me.CountDays.Value = CLng(Me.QStartDays.Value) + CLng(Me.QEndDays.Value)
End Sub
0
 

Author Comment

by:gracie1972
ID: 38811982
What if they want to do a range?  Your VB Code worked.  

However, if there are:

NikeQtr              DaysCount
FY2013 Q1      92
FY2013 Q2      91
FY2013 Q3      59
FY2013 Q4      92

And the user chooses FY2013 Q1  ending  FY2013 Q3  How does can I know to calculate the range of all ?  92+91+59 ?
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 38812056
try this codes


Private Sub QEnd_AfterUpdate()
Me.QEndDays.Value = Me.QEnd.Column(2)
Dim totDays As Long
totDays = DSum("daysCount", "tblFiscalQuarters_2", "[NikeQtr] Between '" & Me.QStart.Column(1) & "' and '" & Me.QEnd.Column(1) & "'")

'Me.CountDays.Value = CLng(Me.QStartDays.Value) + CLng(Me.QEndDays.Value)
Me.CountDays = totDays
End Sub
0
 

Author Comment

by:gracie1972
ID: 38812146
Perfect!  Thanks!
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question