By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,165 Members | 850 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,165 IT Pros & Developers. It's quick & easy.

Procedure too large error

P: 72
Hi can somebody tell me how can i resolve my "PROCEDURE TOO LARGE ERROR",,, my code is too large.. how can i resolve it.
May 18 '07 #1
Share this Question
Share on Google+
10 Replies


Expert 5K+
P: 8,434
I've never heard of that error. What version of Visual Basic is this?

Of course, the obvious answer is "make it smaller". If a procedure is too large, you probably need to break it up into smaller routines.
May 18 '07 #2

Dököll
Expert 100+
P: 2,364
Hi can somebody tell me how can i resolve my "PROCEDURE TOO LARGE ERROR",,, my code is too large.. how can i resolve it.
Listen to him darrel, break it down today, bit by bit. I have had this problem before, assuming you are using VB 6.0. The line of code you are using is too large, even if you build modules to handle some routines, VB will consider the code too long.

One option could be to add an aditional button and plug in the remaining code there, an ugly way of solving this but if you have a number of calls to make in one procedure, VB will be unhappy and will yell at you. There's gotta be an easier way, I stopped there after solving in my primitive fashion:-)

Sorry for your troubles, not fun...
May 19 '07 #3

P: 72
yah i know the only way to solve it is to break it up!!! but i dont know how! i think i need to create a function in a module but i dont know how?? can you give me some details on how can i achieve it.. its like am going to create a function and then calll it in my form everytime i need it.. hope you can help, i cant post my code here coz i will be too long...
May 19 '07 #4

Dököll
Expert 100+
P: 2,364
yah i know the only way to solve it is to break it up!!! but i dont know how! i think i need to create a function in a module but i dont know how?? can you give me some details on how can i achieve it.. its like am going to create a function and then calll it in my form everytime i need it.. hope you can help, i cant post my code here coz i will be too long...
The module will again record length of your routine thus deemed too long per VB. I need you to tell me a little more about your program so I can tell you how to break it down:

(1) Are you seaching/loading a file?
(2) How many command buttons do you have on the form
(3) Do you have sub forms

Answer these and we'll continue. Also it will be helpful to post your code, at least a portion of it to be specific.

In a bit!
May 19 '07 #5

P: 72
Thank you for replying. Yes am Searching with my database, I only have one command button fro now. And i dont know what is a sub form.

To give a background of my program, the program is a time scheduling of subjects in a particular university. Thats wer i work for,,,

I almost have 2400 line of commands,,, it has many selection. e.i. when i chose a particular choice with in my program it has to display details in my form, and the details are in my databse, i think i have a bunch of loops and tables..

Question: How can i combined a loop with diffenrent tables in my databse. heres the code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. 'Time Connection
  3. If rs.State = adStateOpen Then rs.Close
  4.        rs.Open "Select * from [Time]", cnn, adOpenKeyset, adLockOptimistic
  5.     While rs.EOF <> True
  6.         For x = 0 To 7
  7.         Combo1(x).AddItem rs.Fields("Time").Value
  8.         Next x
  9.      rs.MoveNext
  10.     Wend
  11. 'Time Connection
  12.  
  13. 'Room Connection
  14. If rs.State = adStateOpen Then rs.Close
  15.        rs.Open "Select * from [ROOMS]", cnn, adOpenKeyset, adLockOptimistic
  16.   While rs.EOF <> True
  17.     For x = 0 To 7
  18.         Combo2(x).AddItem rs.Fields("ROOM").Value
  19.     Next x
  20.   rs.MoveNext
  21.   Wend
  22. 'Room Connection
  23.  
  24. 'Days Connection
  25. If rs.State = adStateOpen Then rs.Close
  26.        rs.Open "Select * from [DAYS]", cnn, adOpenKeyset, adLockOptimistic
  27.   While rs.EOF <> True
  28.     For x = 0 To 7
  29.         Combo3(x).AddItem rs.Fields("DAYS").Value
  30.     Next x
  31.   rs.MoveNext
  32.   Wend
  33. End If
  34. 'Days Connection
  35.  
  36.  
how can i combined it in one single loop... i have the code with all the lines in my code so far... i always use those code for able for me to load the details in my database i hope youre getting what am trying to say, I hope you can help to simply this code or to teach how can i can a function and just call it up of my form. rhank you
May 19 '07 #6

Expert 5K+
P: 8,434
Unfortunately, this sort of thing depends entirely on your code. The kind of thing you want to look for is anything which is done repeatedly, that you could put into a Sub or Function and call. Anything which can be done independently of the rest of the form. Things like that.

You have to try and work out how you can carve up your code into pieces, then move the pieces into a code module. This may mean setting up globals variables, or you may simply pass the relevant data to/from the routines as parameters and/or function return values.
May 19 '07 #7

P: 72
yes i know thats the solution to my problem, can i just copy paste the code that has been repeatedly done in my form, how can i do it! could you site me some example on how to build a function in a module and call it up when it is needed.. thank you very much
May 19 '07 #8

Dököll
Expert 100+
P: 2,364
yes i know thats the solution to my problem, can i just copy paste the code that has been repeatedly done in my form, how can i do it! could you site me some example on how to build a function in a module and call it up when it is needed.. thank you very much
I hear your pain, darrel. You can get through it...

A sub form by the way is only another form within your main form, it could be included on a frame.

Alright, what must happen when the command button is pressed?

In my case, I was searching/reading/loading text to either a .txt file or MS Access database. I added three button: Search/Commit/View

(1) A portion of the code resided under Search (Added data to part of the form while the form remains invisible

(2) A portion of the code resided under Commit (Added data to part of the form while the form remains invisible

(3) Remaining code resided under View (Added remaining data to form and then form was visible.

What this means, you'll need to figure out a way to have a form that used solelly for searching your database, and only when the View button is pressed should the results form appear...

TIPS: Search button disappears and makes visible Commit buttton, then Commit button disappears to make visible View button. Search form disappears respectively upon entry of your results form

Good luck, and I hope this helps!
May 19 '07 #9

Expert 5K+
P: 8,434
yes i know thats the solution to my problem, can i just copy paste the code that has been repeatedly done in my form, how can i do it! could you site me some example on how to build a function in a module and call it up when it is needed.. thank you very much
Sorry, I'll try to come up with something when I can. Have been extremely busy.
May 21 '07 #10

P: 1
What u can do is in every table add a field SI No
Then Run The Sql

rs.open "Select Time.SINo as Slno ,Time as Time1,Room as Room1,Days as Days1 from [Time],Room,Days where Time.SINo =Room.SINo and Time.SINo =Days.SINo"
While rs.EOF <> True
For x = 0 To 7
Combo1(x).AddItem rs.Fields("TIME").Value
Combo2(x).AddItem rs.Fields("Room").Value
Combo3(x).AddItem rs.Fields("DAYS").Value
Next x
rs.MoveNext
Wend

I'm not sure
jus chk it and try
May 24 '07 #11

Post your reply

Sign in to post your reply or Sign up for a free account.