VBA for Access Error - TechRepublic
Question
January 5, 2009 at 02:33 PM
omnknt232006

VBA for Access Error

by omnknt232006 . Updated 17 years, 6 months ago

I have a database I’ve been working on with several forms and tables and blah blah blah. In the VBA code I have made a function to compute a sum based on the values of several text boxes. The function has worked fine until today when I got this error – “Procedure declaration does not match description of event or procedure having the same name.” Which I thought meant I had fat fingered something. I looked at the code and there are no spelling errors. The only thing I can think of now is that perhaps the scope has been changed somehow so the module can’t see it. Its in the same module though so I’m just stumped.

Function is as follows:
Private Function ComputeTotalAmount() As Currency
‘Sums total fund amounts to put in Total Text box.
‘Populates variables for use in the function.
curPRDJAmount = Me.txtPRDJ_a.Value
curLawconAmount = Me.txtLawcon_a.Value
curOtherAmount = Me.txtOther_a.Value
curFund1Amount = Me.txtFund1_a.Value
curFund2Amount = Me.txtFund2_a.Value
curFund3Amount = Me.txtFund3_a.Value
curFund4Amount = Me.txtFund4_a.Value
curFund5Amount = Me.txtFund5_a.Value
curFund6Amount = Me.txtFund6_a.Value
curFund7Amount = Me.txtFund7_a.Value
curFund8Amount = Me.txtFund8_a.Value
curFund9Amount = Me.txtFund9_a.Value
curFund10Amount = Me.txtFund10_a.Value
‘Reset curTotalFunds variable
curTotalFunds = 0
‘Compute TotalFederalFunds
curTotalFedFunds = curPRDJAmount + curLawconAmount + curOtherAmount
‘Compute curStateFunds Line 1
curStateFundsL1 = curFund1Amount + curFund2Amount + curFund3Amount + curFund4Amount
‘Compute curStateFunds Line 2
curStatefundsL2 = curFund5Amount + curFund6Amount + curFund7Amount + curFund8Amount
‘Compute curStateFunds Line 3
curStateFundsL3 = curFund9Amount + curFund10Amount
‘Compute Total State Funds
curTotalStateFunds = curStateFundsL1 + curStatefundsL2 + curStateFundsL3
‘Compute Total Funds on Form
curTotalFunds = curTotalStateFunds + curTotalFedFunds
Me.txtTotalAmount.Value = curTotalFunds

End Function

The code is set to compute the value during the On Exit event of each of the corresponding text boxes.

An example of the code for the text boxes is as follows:

Private Sub txtFund1_a_Exit(Cancel As Integer)
‘Calls a Function to compute the total amount of all the funds on the form.
Call ComputeTotalAmount

End Sub

If anyone could help me to figure out whats wrong, I would be very appreciative.

This discussion is locked

All Comments