Compile Error

Posted on 2006-04-09
Last Modified: 2007-12-19
I open up an access database and before allowing to do anything it straight away reads:

compile error:
sub or function not defined.

where can you go to place the tick out of the box for this to go away and for the database to open up in peace, i think that's what the problem may be but am looking for help.
Question by:GanaSonaDa
    LVL 119

    Expert Comment

    by:Rey Obrero
    try holding the shift key while opening the db.

    see if the db will open and show the db object window.

    click a form and click design.

    then View>Code

    in the vba window  


    take not of the error that will show and post it here or try to correct.

    good luck...
    LVL 119

    Accepted Solution

    if the forms design view are not enabled ..
    then, the db you are using is in mde format and cannot be modified.

    you have to use the mdb version if it is available if it is not then you cannot do anything with the problem

    Author Comment

    Sorry that was for an older database, my error is: compile error:
    can't find project or library.
    I have made myself an administrator of this app and it says when i click o.k. that i do not have access when selecting design mode.
    this is bizzare as last time i removed some ticks where missing and the like are. need to know how to a) get back there and check b) what ticks are in place or should be in place if not any of them should be removed?
    LVL 27

    Assisted Solution

    Hi GanaSonaDa

    I think some of your References are MISSING
    go to code (VBA) then menu bar > tools > references and uncheck all those checkboxes which say MISSING,

    make a new mdb, then import everything from the old mdb.

    Hi Rey, long time no see :o)

    LVL 8

    Assisted Solution

    You should transfer the old DB to new version, and then do the compile.

    Best Regards

    LVL 26

    Assisted Solution

    by:Alan Warren

    You should be able to create a New Module, Module1
    Then on the Debug Menu > Compile 'Your.mdb'

    This will invoke the VBA compiler, which should Highlight the offending line/lines of code.

    The 'sub or function not defined' error is usually raised when the sub or function being invoked  is  outside the scope of current procedure, you may be able to fix this by locating the sub or function and importing it into the current form code library. Alternatively if you need to reference this sub or or function from multiple  forms you can make the sub or function global by moving it to a New Module.

    The  other thing to check for is the Form's 'hasModule' property.

    Alan ":0)

    Featured Post

    Gigs: Get Your Project Delivered by an Expert

    Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

    Join & Write a Comment

    In the previous article, Using a Critera Form to Filter Records (, the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
    When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
    Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
    In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now