Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-01-23
4
Medium Priority
?
398 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 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

876 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