Procedure Too Large

  • Thread starter Thread starter Jim Jones
  • Start date Start date
J

Jim Jones

I wrote alot of VBA code behind the "On Click" event of a
command button. Upon completion, I'm getting a "Procedure
Too Large" error. Does Access restrict the amount of code
that can be written for each command? How do I correct
this or get around this error?

Thanks,
JJ
 
Jim Jones said:
I wrote alot of VBA code behind the "On Click" event of a
command button. Upon completion, I'm getting a "Procedure
Too Large" error. Does Access restrict the amount of code
that can be written for each command? How do I correct
this or get around this error?


Er, split it into several procedures?

cmdWhatever_Click(...)
do_first
do_second
do_third
end sub

private sub do_first()
....
end sub

(etc.)

But it is rare to hit these limits in practice. How many lines in your
existing procedure, & what does it do?

HTH,
TC
 
I'm using a Select Case based on what the user selects
from a ComboBox. I have 20 case's to write and I have
writen only three of them. Each Case will have about 150
lines of code. So it will require alot of code. Thanks
for the help, I thought that might be the way, but I was
hoping for some kind of a properity change.

8-)
JJ
 
I would _suspect_ that your code could be generalized, but that is really hard
to say. For instance, if you can cut and paste the 150 lines of the first case
and then make a couple of changes in those 150 lines to have it handle the
second case, then I would closely examine the code and see if I could call it as
a subroutine by passing it a couple of parameters.
 
From each case, call a sub or function procedure that resides in a
(separate) standard Module. In fact, it might be better if even those
procedures were broken into smaller units for readability.

Larry Linson
Microsoft Access MVP
 
150 lines is not too many, even for 20 cases. I think
you have another problem. Are you trying to write a
large query? What version of Access are you using.
Prior to XP (not sure about 2000) queries had a limit of
2054 chars (dont hold me to the exact number). XP has
allowed for up to 32000+ chars in a query statement. Do
you have any query statements that may have a large
number of chars?

I do agree with the others when they say to take a large
portion of the code and make it a function or sub call
and either set values or return values based on your
cases. Usually you will find many of the same procedures
within each case and given the length of your code your
overhead will be greatly reduced if you use a subroutine
call.

Drew
 
Use the /decompile command line option to clean up
your MDB.
Create a shortcut to msaccess.exe, and the 'Target'
line, after ......exe", put /decompile.

(david)
 
Jim, I'm sure that you could do this somehow else.

Are there any similarities between the 150-line blocks of code for the
various cases? If so, perhaps each case could call a single procedure,
passing parameter values appropriate to that case.

Could you post (say) the first 30 lines of code from each of the first 3
cases?

TC
 
Back
Top