Question

Locked

VBA for Access Error

By omnknt232006 ·
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 conversation is currently closed to new comments.

9 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Lines

by omnknt232006 In reply to VBA for Access Error

The text box on the site put the line breaks in. They aren't actually that way in my coding. (i.e. curStatefundsL2 = curFund5Amount + curFund6Amount + curFund7Amount + curFund8Amount is all one line)

Collapse -

Anybody?

by omnknt232006 In reply to VBA for Access Error

Anybody out there?

Collapse -

Procedure call

by LarryD4 In reply to VBA for Access Error

You Call to the ComputeTotalAmount shouldn't it have some parens on it?

Call ComputeTotalAmount()

It seems the error is stating that the procedure call is not the same name.

Collapse -

Tried That

by omnknt232006 In reply to Procedure call

I tried that but as soon as I saved the coding it deleted the parenthesis.

Collapse -

Really?

by LarryD4 In reply to Tried That

Did it remove the parens from the actual location of the sub??

Collapse -

Just from the Procedure Call

by omnknt232006 In reply to Really?

The actual function coding still has the parens but anytime I called it I put the parens on but as soon as I saved the codes they disappeared. I think that happens because the parens are empty.

Collapse -

What I don't see

by LarryD4 In reply to VBA for Access Error

Well if you have all the names correct, the only thing I can't confirm as correct is this line..

Me.txtTotalAmount.Value = curTotalFunds

You naming convention for the other amounts is
Me.txtOther_a.Value
So I wold assume that the
Me.txtTotalAmount.Value really should be
Me.txtTotal_a.Value

But I'm just guessing...

Collapse -

Solution

by omnknt232006 In reply to VBA for Access Error

I found what happened. Once I looked at some other routines on the form I encountered the error any time I had an On Exit event. Even when the on exit event didn't relate to the procedure call at all. Before I encountered this error in the coding in Access I had changed one combo box from an on change event to an on exit event by typing it in the top line of the routine instead of copy and pasting it into the on exit event after clicking the builder button on the properties tab. For some reason the entire forms on exit events (15 in all) didn't work. I tried to take a shortcut and ended making more problems for myself. I guess I learned a valuable lesson...

Back to Software Forum
9 total posts (Page 1 of 1)  

Related Discussions

Related Forums