Public Sub GetAccountBudgetandActivity()

   Dim oAccount As CGlAccount

   Dim oUtility As IBBUtilityCode

   Dim oServices As FE_Services

   Dim lAccountID As Long

   Dim sUsername As String

   Dim oSession As IBBSessionContext

   Dim oBudget As CGLBudgetScenario

   Dim oAccountBudget As CGLAccountBudget

   Dim oBudgetDetail As CGLAccountBudgetDetail

   Dim lPeriod As Long

   

   Set oSession = FE_Application.SessionContext

   

   Set oServices = New FE_Services

   oServices.Init oSession

   Set oUtility = oServices

   'Retrieve the system records ID for the GL account

   lAccountID = oUtility.GLAccountIDFromNumber("01-5000-01")

   'Gets the user name for the current user

   sUsername = oUtility.UserGetName(oSession.CurrentUserID)

   'Get the value for the Fiscal Period that 02/01/2002 falls in

   lPeriod = oUtility.GLFiscalPeriodFromDate("02/01/2002")

   Set oUtility = Nothing

   oServices.CloseDown

   Set oServices = Nothing

   

   'Getting budgeted amount for a GL Account

   Set oBudget = New CGLBudgetScenario

   oBudget.Init oSession

   oBudget.Load 8 'loading a specific Budget Scenerio

   Set oAccountBudget = oBudget.AccountBudgets.GetBudgetByAccount("01-5000-01")

   'outputs the account budget for the year

   MsgBox "The account budget for 01-5000-01 for the 2002 year is $" & _

       CCur(oAccountBudget.Fields(GLACCOUNTBUDGETS_fld_AMOUNT))

   Set oBudgetDetail = oAccountBudget.BudgetDetails.GetItemByPeriodID(lPeriod)

   'outputs the account budget for the Fiscal period that include 2/1/2002

   MsgBox "The account budget for 01-5000-01 for the 2002 year February period is $" & _

       CCur(oBudgetDetail.Fields(GLACCOUNTBUDGETDETAILS_fld_AMOUNT))

   Set oBudgetDetail = Nothing

   Set oAccountBudget = Nothing

   

   'Getting the activity for an account after verify current user has rights to the account

   Set oAccount = New CGlAccount

   With oAccount

       .Init oSession

       'verify account can be loaded by current user

       If .CanBeLoaded(lAccountID, csrSecurity) = True Then

           .Load lAccountID

           'outputs the account activity for the month of February 2002

           MsgBox "The account activity for 01-5000-01 for the 2002 year February period is $" & _

                .GetAccountActivity("02/01/2002", "02/28/2002", _

                GLAccountSummary_EncumbranceType_Regular, GLAccountSummary_TranType_Debit)

       Else

           MsgBox sUsername & " does not have permissions to open account 01-5000-01."

       End If

       .CloseDown

   End With

   Set oAccount = Nothing

   oBudget.CloseDown

   Set oBudget = Nothing

   

   Set oSession = Nothing

End Sub

Disclaimer: We provide programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes you are familiar with Microsoft Visual Basic and the tools used to create and debug procedures. Our Customer Support can help explain the functionality of a particular procedure, but we will not modify, or assist you with modifying, these examples to provide additional functionality. If you are interested in learning more about the VBA and API modules, contact your account manager.