Error On Opening Form

M

Miss Teacher

Hi,

This is the third time I've typed this question (it keeps seemingly being
lost or deleted on this forum?? - the second time I even had replies).

On opening my form I get the following message:

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

Here is my On_Open event:

Private Sub Form_Open(Cancel As Integer)
' ChooseOutcomes.Enabled = False
' CriteriaSheet.Enabled = False
' Notes.Enabled = False
' lstAssessmentName.SetFocus
' lstAssessmentName = lstAssessmentName.ItemData(0)
' Call lstAssessmentName_AfterUpdate
End Sub

What I have done thus far:
- checked to see that there is not another form_open event in my programing
- there are no macros on my form
- commented out the entire "Open_form" event and the error still occurs
- deleted and recreated the "Open_form" event
 
C

Clifford Bass

Hi,

There is nothing wrong with that procedure declaration. It is possible
that while it is complaining at one point that the error is actually somwhere
else. Try placing this line at the top of all of your modules, outside of
any procedures:

Option Explicit


The Option Explicit forces you to declare all variables that you use
(with a Dim statement). It can help find typographic errors and also forces
you to be consistent in what you do with the variables. It may help with
procedure declarations also.

Then try doing a compile of the code (Debug menu, Compile
DatabaseName). If the compile finds any problems it will highlight the line
and complain. Fix and repeat the process until it compiles without errors.

If that does not help, try a compact and repair, after making a
backup. If that does not help try a decompile / recompile. See
<http://www.granite.ab.ca/access/decompile.htm> for details.

Hope one of those helps,

Clifford Bass
 
B

boblarson

When you say you "deleted and recreated the "Open_form" event, how exactly
did you recreate it? Did you type it in or did you let Access do it for you
by selecting from the drop down list or by clicking the ellipsis next to
[Event Procedure] in the form's event property? You shouldn't be typing them
yourself, but let Access do it.

I would suggest deleting that event again, and import everything into a new,
blank database file and then add the event through the user interface and NOT
by typing in the parts "Public Sub Form_Open(Cancel As Integer)" yourself.
 
M

Miss Teacher

Hey Clifford!

I solved it!! Yay!!!

For anyone else with this problem I:

- typed "Option Explicit" right at the top on my events method (the VBA
events stuff) - the typing turns blue.
- clicked "Debug" in the menu and chose "Compile [databaseName]"
- The debug took me straight to an UpdateAfter event (Cancel as integer):

Private Sub lstAssessmentName_AfterUpdate() (Cancel As Integer)

'--- whenever a new item is chosen in the list box, display the data in
text boxes
txtAssessmentName = lstAssessmentName.Column(1)
cboAssessmentType = lstAssessmentName.Column(2)
cboYearAssessed = lstAssessmentName.Column(3)
txtImplementDate = lstAssessmentName.Column(4)
txtDueDate = AssessmentName.Column(5)
txtID = AssessmentName.Column(0) '--- primary key is in the first
column (always)

End Sub

....where it told me that there was a variable or something (sorry! I can't
remember the actual wording) that wasn't addressed. That would be the inbuilt
"Cancel" integer. I assume it was wanting to be assigned?
- I commented it out and it worked!

"Private Sub lstAssessmentName_AfterUpdate() '(Cancel As Integer)"

Three days of scratching my head over a " ' "!

So (Clifford or Bob or anyone) if an event has a (Cancel as integer)
parameter that is not being used (created by the ... eclipse by Microsoft),
it should be deleted? Is that right? Just so us rather stupid NOOBs know
:))))). I've read LOTs of tutorials and NONE of them mentioned what to do if
you don't use the parameter.

Sincere thanks to you both for your time and effort. :)
 
M

Miss Teacher

Hey Bob!

I tried importing the database and recreating the event (using the ...
eclipse), but unfortunately, it didn't help :-(. But Cliffords "Option
Explicit" did work (see above).

I'd like to thank you for your time and efforts - I've now learned how to
export a database, and the options for doing so, which will be handy :).

PS - I ALWAYS use the eclipse - I'm not confident (or competent) in doing
otherwise as yet :).

Kind Regards,


boblarson said:
When you say you "deleted and recreated the "Open_form" event, how exactly
did you recreate it? Did you type it in or did you let Access do it for you
by selecting from the drop down list or by clicking the ellipsis next to
[Event Procedure] in the form's event property? You shouldn't be typing them
yourself, but let Access do it.

I would suggest deleting that event again, and import everything into a new,
blank database file and then add the event through the user interface and NOT
by typing in the parts "Public Sub Form_Open(Cancel As Integer)" yourself.
--
Bob Larson
Free MS Access Tutorials and Samples at http://www.btabdevelopment.com

__________________________________


Miss Teacher said:
Hi,

This is the third time I've typed this question (it keeps seemingly being
lost or deleted on this forum?? - the second time I even had replies).

On opening my form I get the following message:

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

Here is my On_Open event:

Private Sub Form_Open(Cancel As Integer)
' ChooseOutcomes.Enabled = False
' CriteriaSheet.Enabled = False
' Notes.Enabled = False
' lstAssessmentName.SetFocus
' lstAssessmentName = lstAssessmentName.ItemData(0)
' Call lstAssessmentName_AfterUpdate
End Sub

What I have done thus far:
- checked to see that there is not another form_open event in my programing
- there are no macros on my form
- commented out the entire "Open_form" event and the error still occurs
- deleted and recreated the "Open_form" event
 
B

Bob Larson

That means that you added that Cancel As Integer as an After Update event
doesn't have that. Again, I reiterate what I said. You really should let
Access manage the events and you just select them and then add to IN BETWEEN
the declaration and the End Sub. You really shouldn't type them in yourself
and you do not want to try to add anything between the parens ( ) because it
will screw things up.

--

Thanks,

Bob Larson
Access MVP

Free Access Tutorials and Resources: http://www.btabdevelopment.com


Miss Teacher said:
Hey Clifford!

I solved it!! Yay!!!

For anyone else with this problem I:

- typed "Option Explicit" right at the top on my events method (the VBA
events stuff) - the typing turns blue.
- clicked "Debug" in the menu and chose "Compile [databaseName]"
- The debug took me straight to an UpdateAfter event (Cancel as integer):

Private Sub lstAssessmentName_AfterUpdate() (Cancel As Integer)

'--- whenever a new item is chosen in the list box, display the data in
text boxes
txtAssessmentName = lstAssessmentName.Column(1)
cboAssessmentType = lstAssessmentName.Column(2)
cboYearAssessed = lstAssessmentName.Column(3)
txtImplementDate = lstAssessmentName.Column(4)
txtDueDate = AssessmentName.Column(5)
txtID = AssessmentName.Column(0) '--- primary key is in the first
column (always)

End Sub

...where it told me that there was a variable or something (sorry! I can't
remember the actual wording) that wasn't addressed. That would be the
inbuilt
"Cancel" integer. I assume it was wanting to be assigned?
- I commented it out and it worked!

"Private Sub lstAssessmentName_AfterUpdate() '(Cancel As Integer)"

Three days of scratching my head over a " ' "!

So (Clifford or Bob or anyone) if an event has a (Cancel as integer)
parameter that is not being used (created by the ... eclipse by
Microsoft),
it should be deleted? Is that right? Just so us rather stupid NOOBs know
:))))). I've read LOTs of tutorials and NONE of them mentioned what to do
if
you don't use the parameter.

Sincere thanks to you both for your time and effort. :)


Clifford Bass said:
Hi,

There is nothing wrong with that procedure declaration. It is
possible
that while it is complaining at one point that the error is actually
somwhere
else. Try placing this line at the top of all of your modules, outside
of
any procedures:

Option Explicit


The Option Explicit forces you to declare all variables that you use
(with a Dim statement). It can help find typographic errors and also
forces
you to be consistent in what you do with the variables. It may help with
procedure declarations also.

Then try doing a compile of the code (Debug menu, Compile
DatabaseName). If the compile finds any problems it will highlight the
line
and complain. Fix and repeat the process until it compiles without
errors.

If that does not help, try a compact and repair, after making a
backup. If that does not help try a decompile / recompile. See
<http://www.granite.ab.ca/access/decompile.htm> for details.

Hope one of those helps,

Clifford Bass
 
C

Clifford Bass

Hi,

Hurrah! Glad to hear it and you are welcome!

It is somewhat odd; that does not even follow the proper way to declare
a subroutine. I have never seen Access create something like that. It might
be a good idea to make sure your version of Windows and MS Office are fully
up-to-date with service packs and any other updates. Go to
<http://update.microsoft.com/> to check.

Clifford Bass

Clifford Bass
 
M

Miss Teacher

Hi Bob!

I will reiterate. I did NOT type this in myself - access created it! I
ALWAYS use the eclipse - I don't know enough about VBA not to. Think about it
- why would I type (and how would I know to type) something like (Cancel as
Integer) after the event declaration - as a beginner I hardly know what that
means. And I have no idea what goes between the parentheses.

I don't know much about Acess and programming, but I DO know what "I",
personally, do on my PC...

Bob Larson said:
That means that you added that Cancel As Integer as an After Update event
doesn't have that. Again, I reiterate what I said. You really should let
Access manage the events and you just select them and then add to IN BETWEEN
the declaration and the End Sub. You really shouldn't type them in yourself
and you do not want to try to add anything between the parens ( ) because it
will screw things up.

--

Thanks,

Bob Larson
Access MVP

Free Access Tutorials and Resources: http://www.btabdevelopment.com


Miss Teacher said:
Hey Clifford!

I solved it!! Yay!!!

For anyone else with this problem I:

- typed "Option Explicit" right at the top on my events method (the VBA
events stuff) - the typing turns blue.
- clicked "Debug" in the menu and chose "Compile [databaseName]"
- The debug took me straight to an UpdateAfter event (Cancel as integer):

Private Sub lstAssessmentName_AfterUpdate() (Cancel As Integer)

'--- whenever a new item is chosen in the list box, display the data in
text boxes
txtAssessmentName = lstAssessmentName.Column(1)
cboAssessmentType = lstAssessmentName.Column(2)
cboYearAssessed = lstAssessmentName.Column(3)
txtImplementDate = lstAssessmentName.Column(4)
txtDueDate = AssessmentName.Column(5)
txtID = AssessmentName.Column(0) '--- primary key is in the first
column (always)

End Sub

...where it told me that there was a variable or something (sorry! I can't
remember the actual wording) that wasn't addressed. That would be the
inbuilt
"Cancel" integer. I assume it was wanting to be assigned?
- I commented it out and it worked!

"Private Sub lstAssessmentName_AfterUpdate() '(Cancel As Integer)"

Three days of scratching my head over a " ' "!

So (Clifford or Bob or anyone) if an event has a (Cancel as integer)
parameter that is not being used (created by the ... eclipse by
Microsoft),
it should be deleted? Is that right? Just so us rather stupid NOOBs know
:))))). I've read LOTs of tutorials and NONE of them mentioned what to do
if
you don't use the parameter.

Sincere thanks to you both for your time and effort. :)


Clifford Bass said:
Hi,

There is nothing wrong with that procedure declaration. It is
possible
that while it is complaining at one point that the error is actually
somwhere
else. Try placing this line at the top of all of your modules, outside
of
any procedures:

Option Explicit


The Option Explicit forces you to declare all variables that you use
(with a Dim statement). It can help find typographic errors and also
forces
you to be consistent in what you do with the variables. It may help with
procedure declarations also.

Then try doing a compile of the code (Debug menu, Compile
DatabaseName). If the compile finds any problems it will highlight the
line
and complain. Fix and repeat the process until it compiles without
errors.

If that does not help, try a compact and repair, after making a
backup. If that does not help try a decompile / recompile. See
<http://www.granite.ab.ca/access/decompile.htm> for details.

Hope one of those helps,

Clifford Bass

:

Hi,

This is the third time I've typed this question (it keeps seemingly
being
lost or deleted on this forum?? - the second time I even had replies).

On opening my form I get the following message:

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

Here is my On_Open event:

Private Sub Form_Open(Cancel As Integer)
' ChooseOutcomes.Enabled = False
' CriteriaSheet.Enabled = False
' Notes.Enabled = False
' lstAssessmentName.SetFocus
' lstAssessmentName = lstAssessmentName.ItemData(0)
' Call lstAssessmentName_AfterUpdate
End Sub

What I have done thus far:
- checked to see that there is not another form_open event in my
programing
- there are no macros on my form
- commented out the entire "Open_form" event and the error still
occurs
- deleted and recreated the "Open_form" event
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top