[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Form Won't Open

Posted on 2004-08-16
3
Medium Priority
?
640 Views
Last Modified: 2010-05-18
I have an odd problem.  I'm writing some forms in my access database, and I can't open some of them.  I don't mean that I can't get the to open with the DoCmd.FormOpen (which I can't do) but I can't even open them to display (only to design).

I've had a similar problem before, but it was that I had an extra end sub in the VB code.  Getting rid of the erroneous line fixed the problem, but I can see no such problem this time.


The error code is 2501, and the error I get when I try to just open the form is:

"The expression On Open you entered as the event property setting produced the following error:
Procedure declaration does not match description of event or procedure having the same name.

*The expression may not result in the name of a macro, the name of a user-defined function or [Event Procedure].
* There may have been an error evaluating the function, event or macro."


Now, the entire amount of code for this form is as follows:

------------------------------------

Option Compare Database

Private Sub Form_BeforeUpdate()
   Controls("property_id") = Field(Me.OpenArgs, "|", 1)
End Sub

Private Sub Form_Close()
    Forms("Application_Single_Property").Requery
End Sub

Private Sub Form_Open(Cancel As Integer)
    Dim stArgument As String
    Dim stTest As String

    stArgument = Field(Me.OpenArgs, "|", 2)
    If Not IsNull(stArgument) Then
        stTest = Left(Me.RecordSource, Len(Me.RecordSource) - 2) & " " & stArgument & ";"
        Me.RecordSource = stTest
        Me.Requery
    End If

End Sub

--------------------------------

Even if I comment out all of the code, leaving just the declarations, I get the same thing.  The properties for the OnOpen, BeforeUpdate and OnClose events are all set to [Event Procedure].  The OnOpen event code is the only code that is new since it stopped working, but even still this code works elsewhere in the program (though I must admit that every form similar to this one is breaking in the same way).

Is there something simple I'm missing?
0
Comment
Question by:Sam_Charette
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 17

Accepted Solution

by:
walterecook earned 500 total points
ID: 11813417
Well I can tell you that the Before Update is missing a parameter.  It should look like this:
Private Sub Form_BeforeUpdate(Cancel As Integer)

Hope that helps
Walt
0
 
LVL 85
ID: 11813445
What is the function "Field"? I'm not familiar with it ... if this is a custom function you've built, then it's also the name of a Reserved word in Access ... change it to something like "fncField" or whatever. If not, then read on ...

If that doesn't do it, try Compiling your code. You may find the answer by doing so - from the VB Edit window, click Debug - Compile. Also try Compacting  (Tools - Compact).

If this doesn't work, I'd create a new, blank database and import all my objects to this (after making a copy of the database, of course). You may have a db that's trying to corrupt the VBA Project (which is most definitely NOT a good thing, as it can render the entire db unusable).  
0
 

Author Comment

by:Sam_Charette
ID: 11813458
Actually, the problem cleared up by putting "Cancel as Integer" in the BeforeUpdate argument list.  It wasn't complaining about that event, but by changing that one it works fine :)

For the record, Field is a custom function that lets me extract portions of a string delineated by a character of my choosing.
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

649 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