• Sub or Function not defined (2003)

    Author
    Topic
    #425913

    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 ?

    Viewing 1 reply thread
    Author
    Replies
    • #982663

      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 to see if the code compiles OK.
      Post back with the results.

    • #982664

      In the OnClick property, do you have [Event Procedure], or do you have a function name?

      • #982712

        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!

        • #982721

          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.

          • #982864

            The error handler reports the wrong error? Oy.

            • #982907

              It isn’t necessarily the *wrong* error, it’s just the one it hits first because of the problem. You get a domino effect. shrug Software has done that as long as I’ve been working with computers (30+ years) sorry

    Viewing 1 reply thread
    Reply To: Sub or Function not defined (2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: