Error code 2501 haunting me

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mhifd009
    New Member
    • Nov 2006
    • 28

    #1

    Error code 2501 haunting me

    I have simple error catch in my code :

    Private Sub ordsch_Click()
    On Error GoTo errhandler
    DoCmd.OpenForm "Order Search"

    errhandler:
    Exit Sub
    End Sub

    The Order search opens a query that has a parameter request for the user to enter a search string, so it allows ok and cancel, if the user enters info - all ok, but if the user clicks cancel then i get error 2501.

    The problem i have is that the error trap worked yesterday and i have not touched this area of code at all today (the coding gremlin has been at large again). I have compiled ok, compressed and repaired.

    Any ideas ?
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    Using your code, I can't replicate your problem. That, together with your statement that it worked the day before and you haven't messed with the code, makes me think that the db has become corrupted. I'd open a new blank db and import everything into it and see what happens.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32669

      #3
      I get a special MS Office problem in Access sometimes when I compile my code.
      It complains about a particular definition line not existing - but it's lying.
      If I Cut the line; recompile; don't worry about error message; Paste the line back in where it was before; Move the cursor from the line; Recompile; then it works again.
      If the compiler doesn't throw an error, maybe you could Cut the whole module; recompile; Paste in the module again; Recompile; Test.

      Comment

      • mhifd009
        New Member
        • Nov 2006
        • 28

        #4
        Sorry its took so long to reply - had to leave the project for a while, i have tried the suggested, and no different, I can go into my project (DB) and the eror doesnt appear, within minutes it can re-appear with no change to coding, maybe i have a corrupt access install - cuz if i put onto the pc where the intended program will sit then i have not seen the problem occur - thanks again for your suggestions.

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32669

          #5
          I'm sorry I can't be more help :(.
          Good luck though.

          Comment

          Working...