Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-01-23
4
Medium Priority
?
397 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
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 …
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…

688 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