Results 1 to 7 of 7
  1. #1
    5 Star Lounger
    Join Date
    May 2003
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    629
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Sub or Function not defined (2003)

    I have a form with several buttons, and they all seem to give me the same error all of a sudden:

    "The expression On Click you entered as the event property setting produced the following error: Sub or Function not defined"

    Many of these buttons are the "Record Nav" butons that the button wizard made for me. One fills a field on the form with a value via algorithim. They all seemed to go bad at the same moment.

    What's more, I have a function written for the Form's "beforeUpdate" event. Trying to close/ave/design the form gives me this error:

    "The expression Before Update you entered as the event property setting produced the following error: Sub or Function not defined"

    It's like the form has lost the pointers to the proper code. It's all there though,none of the names have been changed. I even renamed a control. Same error.

    "Help" is incredibly unhelpful, as always.

    Since I've had this happen to me not too long ago in a different database, I suspect this is a known problem. Unfortunately, not known to me.

    Any ideas ?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Sub or Function not defined (2003)

    Let's check for missing references first:
    - Activate the Visual Basic Editor.
    - Select Tools | References...
    - If there are references starting with missing, note which ones they are, then clear their check boxes.
    - Click OK.
    - Select Debug | Compile <project name> to see if the code compiles OK.
    Post back with the results.

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Sub or Function not defined (2003)

    In the OnClick property, do you have [Event Procedure], or do you have a function name?
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    5 Star Lounger
    Join Date
    May 2003
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    629
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Sub or Function not defined (2003)

    Turns out I had a typo in the newest on-clik event. As soon as I corrected it, the error messages went away.

    Well aside from me failing my obvious responsibility to write error-free code, what just happened here?

    I guess it did a compile on the spot when I tried to press a button. But when I was compiling in the VB editor. it took me to the offending line and gave me at least a useful error. I don't understand the behavior of popping up and error on an unrelated control that suggests the problem is with an object that it obviously isn't in!

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Sub or Function not defined (2003)

    Errors like this, or a missing reference, often throw VBA out of kilter, causing it to report an error seemingly unrelated to the real problem in runtime. That's why it is useful to select Debug | Compile in the Visual Basic Editor.

  6. #6
    5 Star Lounger
    Join Date
    May 2003
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    629
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Sub or Function not defined (2003)

    The error handler reports the wrong error? Oy.

  7. #7
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Sub or Function not defined (2003)

    It isn't necessarily the *wrong* error, it's just the one it hits first because of the problem. You get a domino effect. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15> Software has done that as long as I've been working with computers (30+ years) <img src=/S/sorry.gif border=0 alt=sorry width=15 height=15>
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •