Public Sub AddBudget()

Dim dtBudgetDate As Date
Dim sScenarioId As String
Dim sScenarioDescription As String
Dim sBudgetType As String
Dim sAccountBudgetId As String
Dim dAccountBudgetAmount As Double
Dim dBudgetDetailAmount As Double
Dim sProjectBudgetId As String
Dim sTCodeID As String
Dim dProjectBudgetAmount As Double
Dim dProjectBudgetDetailAmount As Double

dtBudgetDate = "04-01-2008"
sScenarioId = "99"
sScenarioDescription = "30% Above Projected Cost"
sBudgetType = "Fiscal Year"
sAccountBudgetId = "01-1030-00"
dAccountBudgetAmount = 1200
dBudgetDetailAmount = 100
sProjectBudgetId = "1001"
sTCodeID = "Elder Care"
dProjectBudgetAmount = 120
dProjectBudgetDetailAmount = 10

Dim oBudgetScenario As CGLBudgetScenario

Dim oUtil As IBBUtilityCode
Dim goFE_Service As FE_Services
Set goFE_Service = New FE_Services
goFE_Service.Init FE_Application.SessionContext
Set oUtil = goFE_Service
Set oBudgetScenario = New CGLBudgetScenario
Dim oCode As CCodeTablesServer
Set oCode = goFE_Service.CreateServiceObject(bbsoCodeTablesServer)
oCode.Init FE_Application.SessionContext

With oBudgetScenario
.Init FE_Application.SessionContext
'Set the fiscal year and scenario fields
oCode.GetTableEntryID(sScenarioDescription, ctnumGLBudgetScenarios)

With .AccountBudgets.Add
'Add required fields
.Fields(GLACCOUNTBUDGETS_fld_AMOUNT) = dAccountBudgetAmount

'Set Account Budget Detail amounts
Dim oBudgetDetail As CGLAccountBudgetDetail
For Each oBudgetDetail In .BudgetDetails
Next oBudgetDetail
'Create a project budget
With .ProjectBudgets.Add
.Fields(GLPROJECTBUDGETS_fld_AMOUNT) = dProjectBudgetAmount
Dim oProjectDetail As CGLProjectBudgetDetail
Dim lPeriod As Long
'Set Project Budget Detail amounts
Dim oBD As IBBGLProjectGrantBudgetDetails
Set oBD = .BudgetDetails
For lPeriod = 1 To 12
oBD.AddByPeriodSequence(lPeriod).Fields(GLPROJECTBUDGETDETAILS_fld_AMOUNT) = _
Next lPeriod

End With

End With
End With
Set oBudgetScenario = 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. Blackbaud Customer Support may help explain the functionality of a particular procedure, but we will not modify, or assist you with modifying, these examples to provide additional functionality.