Solved

Table Development question

Posted on 2014-09-03
6
166 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
  • 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 49

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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

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 49

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

920 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

14 Experts available now in Live!

Get 1:1 Help Now