Hello everyone,
I have a code that takes Access form info, transfers it to an excel template. works well, until now.
I had to create a new template and depending on data in the population determine which form to open.
So if there is a flag open one template, otherwise open the other.
My code is below. Im stuck on how to enter the End If's I keep getting errors. I've moved the End Ifs around a little to trouble shoot... going to pound head against wall now!!!
Any help would be appreciated.
On Error GoTo Err_Value_Calculation_Click
Dim oXL As Object
Dim oExcel As Object
Dim sFullPath As String
Dim sPath As String
If Value.Me.EMPLOYEE_CATEGORY_NAME = "Y" Then
Set oXL = CreateObject("Excel.Application")
sFullPath = CurrentProject.Path & "\Participants\Templates\Code Staff Stock Outstanding Template"
End If
With oXL
.Visible = True
.workbooks.Open (sFullPath)
.Range("A8").Value = Me.[Active_Terms_Sept_End.Name].Value
.Range("c10").Value = Me.[2009 Award Plan.TOTAL_INITIAL_DEFERRED_AWARD].Value
.Range("c12").Value = Me.[June2010_Principle].Value
.Range("e12").Value = Me.[June2010_Interest].Value
.Range("f12").Value = Me.[Total_2010_Pmt].Value
.Range("c13").Value = Me.[June2011_Principle].Value
.Range("e13").Value = Me.[June2011_Interest].Value
.Range("f13").Value = Me.[Total_2011_Pmt].Value
.Range("c14").Value = Me.[June2012_Principle].Value
.Range("e14").Value = Me.[June2012_Interest].Value
.Range("f14").Value = Me.[Total_2012_Pmt].Value
.Range("c17").Value = Me.[2010 Award Plan.TOTAL_DEFERRED_AWARD].Value
.Range("c19").Value = Me.[June2010_Vesting_Principle].Value
.Range("e19").Value = Me.[June2010_Vesting_Interest].Value
.Range("h19").Value = Me.[June2010_Payment_Type].Value
.Range("i20").Value = Me.[June2011_Payment].Value
.Range("h20").Value = Me.[June2011_Payment_Type].Value
.Range("i21").Value = Me.[June2012_Payment].Value
.Range("h21").Value = Me.[June2012_Payment_Type].Value
.Range("c24").Value = Me.[2010 Top Slice Plan.TOTAL_INITIAL_DEFERRED_AWARD].Value
.Range("c26").Value = Me.[January2011_Vesting_Principle].Value
.Range("h26").Value = Me.[January2011_Payment_Type].Value
.Range("i26").Value = Me.[January2011_Shares].Value
.Range("c27").Value = Me.[January2012_Vesting_Principle].Value
.Range("h27").Value = Me.[January2012_Payment_Type].Value
.Range("i27").Value = Me.[January2012_Shares].Value
.Range("c28").Value = Me.[January2013_Vesting_Principle].Value
.Range("h28").Value = Me.[January2013_Payment_Type].Value
.Range("i28").Value = Me.[January2013_Shares].Value
If Value.Me.EMPLOYEE_CATEGORY_NAME Is Null Then
Set oXL = CreateObject("Excel.Application")
sFullPath = CurrentProject.Path & "\Participants\Templates\Stock Outstanding Template"
End If
With oXL
.Visible = True
.workbooks.Open (sFullPath)
.Range("A8").Value = Me.[Active_Terms_Sept_End.Name].Value
.Range("c10").Value = Me.[2009 Award Plan.TOTAL_INITIAL_DEFERRED_AWARD].Value
.Range("c12").Value = Me.[June2010_Principle].Value
.Range("e12").Value = Me.[June2010_Interest].Value
.Range("f12").Value = Me.[Total_2010_Pmt].Value
.Range("c13").Value = Me.[June2011_Principle].Value
.Range("e13").Value = Me.[June2011_Interest].Value
.Range("f13").Value = Me.[Total_2011_Pmt].Value
.Range("c14").Value = Me.[June2012_Principle].Value
.Range("e14").Value = Me.[June2012_Interest].Value
.Range("f14").Value = Me.[Total_2012_Pmt].Value
.Range("c17").Value = Me.[2010 Award Plan.TOTAL_DEFERRED_AWARD].Value
.Range("c19").Value = Me.[June2010_Vesting_Principle].Value
.Range("e19").Value = Me.[June2010_Vesting_Interest].Value
.Range("h19").Value = Me.[June2010_Payment_Type].Value
.Range("i20").Value = Me.[June2011_Payment].Value
.Range("h20").Value = Me.[June2011_Payment_Type].Value
.Range("i21").Value = Me.[June2012_Payment].Value
.Range("h21").Value = Me.[June2012_Payment_Type].Value
.Range("c24").Value = Me.[2010 Top Slice Plan.TOTAL_INITIAL_DEFERRED_AWARD].Value
.Range("c26").Value = Me.[January2011_Vesting_Principle].Value
.Range("h26").Value = Me.[January2011_Payment_Type].Value
.Range("i26").Value = Me.[January2011_Shares].Value
.Range("c27").Value = Me.[January2012_Vesting_Principle].Value
.Range("h27").Value = Me.[January2012_Payment_Type].Value
.Range("i27").Value = Me.[January2012_Shares].Value
.Range("c28").Value = Me.[January2013_Vesting_Principle].Value
.Range("h28").Value = Me.[January2013_Payment_Type].Value
.Range("i28").Value = Me.[January2013_Shares].Value
End With
Exit_Value_Calculation_Click:
Exit Sub
Err_Value_Calculation_Click:
MsgBox Err.Description
Resume Exit_Value_Calculation_Click
End Sub
I have a code that takes Access form info, transfers it to an excel template. works well, until now.
I had to create a new template and depending on data in the population determine which form to open.
So if there is a flag open one template, otherwise open the other.
My code is below. Im stuck on how to enter the End If's I keep getting errors. I've moved the End Ifs around a little to trouble shoot... going to pound head against wall now!!!
Any help would be appreciated.
CODE:
Private Sub Value_Calculation_Click()On Error GoTo Err_Value_Calculation_Click
Dim oXL As Object
Dim oExcel As Object
Dim sFullPath As String
Dim sPath As String
If Value.Me.EMPLOYEE_CATEGORY_NAME = "Y" Then
Set oXL = CreateObject("Excel.Application")
sFullPath = CurrentProject.Path & "\Participants\Templates\Code Staff Stock Outstanding Template"
End If
With oXL
.Visible = True
.workbooks.Open (sFullPath)
.Range("A8").Value = Me.[Active_Terms_Sept_End.Name].Value
.Range("c10").Value = Me.[2009 Award Plan.TOTAL_INITIAL_DEFERRED_AWARD].Value
.Range("c12").Value = Me.[June2010_Principle].Value
.Range("e12").Value = Me.[June2010_Interest].Value
.Range("f12").Value = Me.[Total_2010_Pmt].Value
.Range("c13").Value = Me.[June2011_Principle].Value
.Range("e13").Value = Me.[June2011_Interest].Value
.Range("f13").Value = Me.[Total_2011_Pmt].Value
.Range("c14").Value = Me.[June2012_Principle].Value
.Range("e14").Value = Me.[June2012_Interest].Value
.Range("f14").Value = Me.[Total_2012_Pmt].Value
.Range("c17").Value = Me.[2010 Award Plan.TOTAL_DEFERRED_AWARD].Value
.Range("c19").Value = Me.[June2010_Vesting_Principle].Value
.Range("e19").Value = Me.[June2010_Vesting_Interest].Value
.Range("h19").Value = Me.[June2010_Payment_Type].Value
.Range("i20").Value = Me.[June2011_Payment].Value
.Range("h20").Value = Me.[June2011_Payment_Type].Value
.Range("i21").Value = Me.[June2012_Payment].Value
.Range("h21").Value = Me.[June2012_Payment_Type].Value
.Range("c24").Value = Me.[2010 Top Slice Plan.TOTAL_INITIAL_DEFERRED_AWARD].Value
.Range("c26").Value = Me.[January2011_Vesting_Principle].Value
.Range("h26").Value = Me.[January2011_Payment_Type].Value
.Range("i26").Value = Me.[January2011_Shares].Value
.Range("c27").Value = Me.[January2012_Vesting_Principle].Value
.Range("h27").Value = Me.[January2012_Payment_Type].Value
.Range("i27").Value = Me.[January2012_Shares].Value
.Range("c28").Value = Me.[January2013_Vesting_Principle].Value
.Range("h28").Value = Me.[January2013_Payment_Type].Value
.Range("i28").Value = Me.[January2013_Shares].Value
If Value.Me.EMPLOYEE_CATEGORY_NAME Is Null Then
Set oXL = CreateObject("Excel.Application")
sFullPath = CurrentProject.Path & "\Participants\Templates\Stock Outstanding Template"
End If
With oXL
.Visible = True
.workbooks.Open (sFullPath)
.Range("A8").Value = Me.[Active_Terms_Sept_End.Name].Value
.Range("c10").Value = Me.[2009 Award Plan.TOTAL_INITIAL_DEFERRED_AWARD].Value
.Range("c12").Value = Me.[June2010_Principle].Value
.Range("e12").Value = Me.[June2010_Interest].Value
.Range("f12").Value = Me.[Total_2010_Pmt].Value
.Range("c13").Value = Me.[June2011_Principle].Value
.Range("e13").Value = Me.[June2011_Interest].Value
.Range("f13").Value = Me.[Total_2011_Pmt].Value
.Range("c14").Value = Me.[June2012_Principle].Value
.Range("e14").Value = Me.[June2012_Interest].Value
.Range("f14").Value = Me.[Total_2012_Pmt].Value
.Range("c17").Value = Me.[2010 Award Plan.TOTAL_DEFERRED_AWARD].Value
.Range("c19").Value = Me.[June2010_Vesting_Principle].Value
.Range("e19").Value = Me.[June2010_Vesting_Interest].Value
.Range("h19").Value = Me.[June2010_Payment_Type].Value
.Range("i20").Value = Me.[June2011_Payment].Value
.Range("h20").Value = Me.[June2011_Payment_Type].Value
.Range("i21").Value = Me.[June2012_Payment].Value
.Range("h21").Value = Me.[June2012_Payment_Type].Value
.Range("c24").Value = Me.[2010 Top Slice Plan.TOTAL_INITIAL_DEFERRED_AWARD].Value
.Range("c26").Value = Me.[January2011_Vesting_Principle].Value
.Range("h26").Value = Me.[January2011_Payment_Type].Value
.Range("i26").Value = Me.[January2011_Shares].Value
.Range("c27").Value = Me.[January2012_Vesting_Principle].Value
.Range("h27").Value = Me.[January2012_Payment_Type].Value
.Range("i27").Value = Me.[January2012_Shares].Value
.Range("c28").Value = Me.[January2013_Vesting_Principle].Value
.Range("h28").Value = Me.[January2013_Payment_Type].Value
.Range("i28").Value = Me.[January2013_Shares].Value
End With
Exit_Value_Calculation_Click:
Exit Sub
Err_Value_Calculation_Click:
MsgBox Err.Description
Resume Exit_Value_Calculation_Click
End Sub