Hi,
I have a control on a form which has an AfterUpdate event which should automatically update another control. See below:
The code should look up the financial year ID from the FinancialYears table and add this to the grant record but it doesn't always work and I can't see why. When approving, the approver adds in their name in a drop down and then the date of the approval in this control. Once those details are added they then have to click a save button. If whoever adds the date to the 'Approval' control is not pressing Enter or tabbing from the control before they press the save button could this prevent the AfterUpdate event from triggering?
Is there a better way to achieve what I need to achieve? I need to add the financial year into each grant to ensure that the funding comes from the correct years budget and is easily reported on.
I have a control on a form which has an AfterUpdate event which should automatically update another control. See below:
Code:
Private Sub Approval_AfterUpdate()
On Error GoTo ErrorHandler
'Passes financial year ID to grant record based on approval date
If Me.Recommendation = "Approval" Then
Me.FinancialYear = DLookup("FinancialYearID", "FinancialYearsT", "StartDate<=#" & _
Me.Approval & "# AND EndDate>#" & Me.Approval & "#")
'Update payment status, payment amount, status and status date
Me.PaymentStatus = "Awaiting authorisation"
Me.PaymentAmount = Me![TotalRequested]
Me.Status = "Decision"
Me.StatusDate = Me![Approval]
End If
'Update status and status date
If Me.Recommendation = "Rejection" Then
Me.Status = "Rejected"
Me.StatusDate = Me![Approval]
End If
Exit Sub
ErrorHandler:
Dim msg As String
msg = Err.Number & ":" & Err.Description
MsgBox msg
End Sub
The code should look up the financial year ID from the FinancialYears table and add this to the grant record but it doesn't always work and I can't see why. When approving, the approver adds in their name in a drop down and then the date of the approval in this control. Once those details are added they then have to click a save button. If whoever adds the date to the 'Approval' control is not pressing Enter or tabbing from the control before they press the save button could this prevent the AfterUpdate event from triggering?
Is there a better way to achieve what I need to achieve? I need to add the financial year into each grant to ensure that the funding comes from the correct years budget and is easily reported on.