Solved

Table Development question

Posted on 2014-09-03
6
171 Views
Last Modified: 2014-09-04
Experts, I am developing a table but need a little help.  

I have :
ID
[Description]
[Type]
[WithinDays]
[Type]

I have many reporting requirements and they are either Quarterly, Semiannually, Annually and within a certain number of days past those points.  For example, an annual report would be within 120 days after years end and a quarterly is within 60 days past the quarter.  

My question is, do I hard code [withindays] (ie 120, 60) as a field in a table?  Or is it better some other way (maybe within a query)

thank you
0
Comment
Question by:pdvsa
[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
  • 3
  • 2
6 Comments
 
LVL 2

Accepted Solution

by:
Priya Sudharsan earned 250 total points
ID: 40302667
Do not hard code it. Have the data alone in the table and build queries as per the reporting criteria for each reports.
0
 
LVL 50

Assisted Solution

by:Gustav Brock
Gustav Brock earned 250 total points
ID: 40302929
That would be an Integer. Then you can use DateAdd and DateDiff to find dates or calculate day passed relative to, say, quarter end or quarter start.

To identify various parts of a year, this function can be helpful:
Public Function DatePartYear( _
    ByVal strInterval As String, _
    ByVal datDate As Date) _
    As Integer
    
' Returns the part of the year of datDate according to strInterval.
'
' 2008-02-07. Cactus Data ApS, CPH.
    
    Const cMonthsInYear As Integer = 12
    
    Dim intYearPart     As Integer
    Dim intYearParts    As Integer
    
    Select Case strInterval
        Case "y", "m", "q"
            ' Day, Month, or Quarter of a year.
            intYearPart = DatePart(strInterval, datDate)
        Case "i"
            ' Dimidiae. Half part of a year.
            intYearParts = 2
        Case "t"
            ' Tertia. Third part of a year.
            intYearParts = 3
        Case "x"
            ' Sexta. Sixth part of a year.
            intYearParts = 6
    End Select

    If intYearParts > 0 Then
        intYearPart = -Int(-Month(datDate) / (cMonthsInYear / intYearParts))
    End If

    DatePartYear = intYearPart

End Function

Open in new window

And to find, say, first or last date of a quarter, these can be used:
Public Function DateThisQuarterFirst( _
  Optional ByVal datDateThisQuarter As Date) As Date
  
  Const cintQuarterMonthCount   As Integer = 3
  
  Dim intThisMonth              As Integer
  
  If datDateThisQuarter = 0 Then
    datDateThisQuarter = Date
  End If
  intThisMonth = (DatePart("q", datDateThisQuarter) - 1) * cintQuarterMonthCount

  DateThisQuarterFirst = DateSerial(Year(datDateThisQuarter), intThisMonth + 1, 1)

End Function

Public Function DateThisQuarterLast( _
  Optional ByVal datDateThisQuarter As Date) As Date
  
  Const cintQuarterMonthCount   As Integer = 3
  
  Dim intThisMonth              As Integer
  
  If datDateThisQuarter = 0 Then
    datDateThisQuarter = Date
  End If
  intThisMonth = DatePart("q", datDateThisQuarter) * cintQuarterMonthCount
  
  DateThisQuarterLast = DateSerial(Year(datDateThisQuarter), intThisMonth + 1, 0)

End Function

Open in new window

Just examples.

/gustav
0
 

Author Closing Comment

by:pdvsa
ID: 40303216
thank you.  I plan to use those functions so I think a split is acceptable. Let me know if there is an objection.  

thanks again.
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

Author Comment

by:pdvsa
ID: 40303471
Gustav:  could you give me a quick example of how I would use those functions?  Meaning I would first identify the end of quarter with the first function and then use DateADD to add X days?  I guess I would call the function in the query design window.  thank you for your help.  I am glad you responded.  I remember you are excellent with dates and technical questions.  I am a little rusty as have not worked in Access in some time.
0
 
LVL 50

Expert Comment

by:Gustav Brock
ID: 40303573
You could ask:

"When is the next reports ultimo this quarter?"

    datNextThisQuarter = DateThisQuarterLast(Date)

"What is the deadline of this? If within 30 days:

    intMaxDelay = 30
    datNextThisQuarterLatest = DateAdd("d", intMaxDelay, DateThisQuarterLast(Date))

But there are, of course, many variations over this.

/gustav
0
 

Author Comment

by:pdvsa
ID: 40303938
very nice.  thank you.  I will be playing around with this.  thanks again for the codes.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
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…
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…

763 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