473,320 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Sub or Function not defined problem

Seth Schrock
2,965 Expert 2GB
I have the following lines of code among others in my database
Expand|Select|Wrap|Line Numbers
  1. Dim modModule As CodeModule
  2. Set modModule = Application.VBE.ActiveVBProject.VBComponents(strModule).CodeModule
  3. lngStartLine = modModule.ProcStartLine(strProcedure, vbext_pk_Proc)
When this code runs, I'm getting an error message highlighting line 3 saying "Sub or Function not defined". If I hover over strProcedure, I get the proper value. If I hover over vbext_pk_Proc I get the value 0 (as I should). If I hover over the .ProcStartLine, it shows the same error. I have the reference set to Microsoft Visual Basic for Applications Extensibility 5.3. If I go to the Object Browser, it lists ProcStartLine as one of the properties of the CodeModule object. I even get intellisense for it. So why am I getting this error message? I have even tried removing the reference and setting it again. It works on another database, but not on this one. Any ideas?
Aug 21 '15 #1

✓ answered by TheSmileyCoder

At the risk of offending your intelligence :)

And you have double checked that the procedure name in strProcedure actually exists in the module?

11 2324
jimatqsi
1,271 Expert 1GB
What is strModule? What version of Access are you running? Do you have multiple versions installed on that machine?

Jim
Aug 22 '15 #2
TheSmileyCoder
2,322 Expert Mod 2GB
Could you be running it on an empty code module`?
Aug 22 '15 #3
Seth Schrock
2,965 Expert 2GB
This is just an excerpt from a larger project described in this post: How to navigate to a specific procedure in a module or class module. I got it to work in one database, but when I tried to copy it over to another database, it won't work.

strModule is a variable containing the name of the module to which I want to navigate.

@TheSmileyCoder I'm not sure which way you are asking. The code is being run in a module that only has this one procedure in it. The module that I'm referencing also has code in it.
Aug 23 '15 #4
TheSmileyCoder
2,322 Expert Mod 2GB
I see. That kinda code is often seen where you loop through all the modules. My line of thought was that maybe one of the modules being looped over was empty, and thus had no procedure.

Have you tried a decompile on the app?
Aug 23 '15 #5
NeoPa
32,556 Expert Mod 16PB
ProcStartLine seems to be 2010 and forwards only. Which version are you running with?

Do you have references set to all the libraries you need?

Is the installation of Access set up to trust programming access to the project in the options?
Aug 23 '15 #6
Seth Schrock
2,965 Expert 2GB
I'm using Access 2010 both on the working database and on the non-working database. I find the function in the Object Browser, so I would assume that I have the reference needed. And I do have the database setup in a trusted location.

I will try to decompile it tomorrow when I go to work.
Aug 23 '15 #7
TheSmileyCoder
2,322 Expert Mod 2GB
Does the "trouble"some database compile without issues?
Aug 24 '15 #8
Seth Schrock
2,965 Expert 2GB
I decompiled it and then compiled it again. It compiled without any issues (as it did before) and I'm still getting the same error message.
Aug 24 '15 #9
TheSmileyCoder
2,322 Expert Mod 2GB
At the risk of offending your intelligence :)

And you have double checked that the procedure name in strProcedure actually exists in the module?
Aug 24 '15 #10
Seth Schrock
2,965 Expert 2GB
Ouch. That hurts. It didn't exist :( The line that I was parsing was
Expand|Select|Wrap|Line Numbers
  1. Error 3061 has occured in procedure [cmdDelete_OnClick] in module [Form_frmEmployee] on line [130] Too few parameters. Expected 1.
Somehow the name of the procedure was entered as cmdDelete_OnClick instead of cmdDelete_Click. I guess that I didn't even think to question that since it was saying that it couldn't find the sub or function. Even when I first checked I didn't notice the OnClick difference.

Thanks to everyone for your help and thank-you Smiley for pointing out my error. :)
Aug 24 '15 #11
NeoPa
32,556 Expert Mod 16PB
Seth:
Ouch. That hurts. It didn't exist :(
I feel that. That's always a hard one to spot actually. I guess we all understand how hard as we've all done it ourselves before.
Aug 24 '15 #12

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

Similar topics

5
by: danny.myint | last post by:
I was under the assumption that javascript loads all the <head></head> elements before processing the <body> tag in Mozilla/Netscape/Firefox. It doesn't seem like it, with my problem. I have...
5
by: rashmi | last post by:
how to use static function defined in one file in another file is that impposiible in 'c '
12
by: jeniffer | last post by:
Can a static function defined in a C file be ever referred (called) externally from another C file?If so in which conditions?
78
by: Josiah Manson | last post by:
I found that I was repeating the same couple of lines over and over in a function and decided to split those lines into a nested function after copying one too many minor changes all over. The only...
19
by: thisis | last post by:
Hi All, i have this.asp page: <script type="text/vbscript"> Function myFunc(val1ok, val2ok) ' do something ok myFunc = " return something ok" End Function </script>
17
by: Navaidstech | last post by:
Hi all... I'm new to Java programming. I've seen how finicky java is as far case and space sensitivity sensitivity is concerned. However, I'm slowly getting hang of it. I came accross this...
3
by: ADS7328 | last post by:
Dear everybody, I trying to compile an aplication and i have got the following error during linking phase: ld: fatal: symbol `K_MultiHandler_c::~K_MultiHandler_c #Nvariant 1()' is...
6
by: cppnow | last post by:
Hello. I have a strange conceptual problem I'm trying to think about. I would like to build a library that allows the user to do the following: 1) User defined types: The user defines their...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.