Solved

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

Posted on 2013-01-23
4
389 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 119

Expert Comment

by:Rey Obrero
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 119

Accepted Solution

by:
Rey Obrero 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
This collection of functions covers all the normal rounding methods of just about any numeric value.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now