I am using access 2003. I am trying to write a function that will populate 12 cells on a spreadsheet with the fiscal month on them. The problem I am having is as soon as my calculation gets to 0 I get an error, this makes sense to me on why I get an error but I dont know what I can do differently to overcome this problem. Any help is greatly appreciated.
Tom
Tom
Code:
Option Compare Database
Option Explicit
Public Function CurRptMon(pd As Integer, strCurRptMon As String, iCurMon As Integer, iCurYr As Integer) As Integer
Dim dtCurDate As Date
Dim dtCurMon As Date
Dim dtMonthName As Date
Dim iCurPd As Integer
Dim iCurRptMon As Integer
Dim iCurMonPd As Integer
Dim ipdCalc As Integer
Dim ipdMonCalc As Integer
Dim strCurMon As String
dtCurDate = Date
iCurYr = Year(dtCurDate)
iCurMon = Month(dtCurDate)
iCurRptMon = iCurMon - 1
strCurRptMon = MonthName(iCurRptMon, False)
strCurMon = MonthName(iCurMon, True)
ipdCalc = 359
ipdMonCalc = 12
If iCurYr = 2013 Then ipdCalc = ipdCalc + ipdMonCalc
If iCurYr = 2014 Then ipdCalc = ipdCalc + (ipdMonCalc * 2)
If iCurYr = 2015 Then ipdCalc = ipdCalc + (ipdMonCalc * 3)
If iCurYr = 2016 Then ipdCalc = ipdCalc + (ipdMonCalc * 4)
pd = ipdCalc + iCurMon
End Function
Call CurRptMon(pd, strCurRptMon, iCurMon, iCurYr)
Option Compare Database
Option Explicit
Public Function SetTitle()
Dim strTitle1Name As String
Dim strTitle2Name As String
Dim strColTitle1Name As String
Dim strColTitle2Name As String
Dim strColTitle3Name As String
Dim strColTitle4Name As String
Dim strColTitle5Name As String
Dim strColTitle6Name As String
Dim strColTitle7Name As String
Dim strColTitle8Name As String
Dim strColTitle9Name As String
Dim strColTitle10Name As String
Dim strColTitle11Name As String
Dim strColTitle12Name As String
strTitle1Name = "PROCEDURES BY SERVICE PROVIDER - FISCAL " & iCurYr
strTitle2Name = "HOSPITALIST PROGRAM"
With goXL.ActiveSheet
.Cells(1, 1).Value = strTitle1Name
.Cells(2, 1).Value = strTitle2Name
strColTitle1Name = "UCI"
strColTitle2Name = "SERVICE PROVIDER"
strColTitle3Name = MonthName(iCurMon - 12, True)
strColTitle4Name = MonthName(iCurMon - 11, True)
strColTitle5Name = MonthName(iCurMon - 10, True)
strColTitle6Name = MonthName(iCurMon - 9, True)
strColTitle7Name = MonthName(iCurMon - 8, True)
strColTitle8Name = MonthName(iCurMon - 7, True)
strColTitle9Name = MonthName(iCurMon - 6, True)
strColTitle10Name = MonthName(iCurMon - 5, True)
strColTitle11Name = MonthName(iCurMon - 4, True)
strColTitle12Name = MonthName(iCurMon - 3, True)
strColTitle13Name = MonthName(iCurMon - 2, True)
strColTitle14Name = MonthName(iCurMon - 1, True)
iCol = 4
'.Cells(iCol, 1).Value = strColTitle1Name
'.Cells(iCol, 2).Value = strColTitle2Name
'.Cells(iCol, 3).Value = strColTitle3Name
'.Cells(iCol, 4).Value = strColTitle4Name
'.Cells(iCol, 5).Value = strColTitle5Name
'.Cells(iCol, 6).Value = strColTitle6Name
'.Cells(iCol, 7).Value = strColTitle7Name
'.Cells(iCol, 8).Value = strColTitle8Name
'.Cells(iCol, 9).Value = strColTitle9Name
'.Cells(iCol, 10).Value = strColTitle10Name
'.Cells(iCol, 11).Value = strColTitle11Name
.Cells(iCol, 12).Value = strColTitle12Name
.Cells(iCol, 13).Value = strColTitle13Name
.Cells(iCol, 14).Value = strColTitle14Name
End With
End function