error on opening form

S

smk23

I start getting the following error message on opening nearly every form in
my application:
"The expression On Current you entered as the event property setting
produced the following error: statement invalid outside type block."

The form I was opening does have code on the On Current event, but when I
put a breakpoint there, it never gets to the code. The form proceeds to open
and seems to otherwise function normally except if I click a command button,
I get the same line with "the expression On Click..." I can't find a way to
debug this. Any ideas appreciated.

Thanks,
Sam
 
S

smk23

Just found the answer, FYI in case anyone else gets this weird situation:
I had declared a variable in a module header of a form but forgot the "Dim".
This affected nearly every form in the application. I would have found this
faster if I had compiled my code (which I can't believe I hadn't).

Thanks,
Sam
 
S

Stuart McCall

smk23 said:
I start getting the following error message on opening nearly every form in
my application:
"The expression On Current you entered as the event property setting
produced the following error: statement invalid outside type block."

The form I was opening does have code on the On Current event, but when I
put a breakpoint there, it never gets to the code. The form proceeds to
open
and seems to otherwise function normally except if I click a command
button,
I get the same line with "the expression On Click..." I can't find a way
to
debug this. Any ideas appreciated.

Thanks,
Sam

Sounds like you have an expression in the form's OnCurrent Property. Open
your form in design view, open the property sheet and click on the Event
tab. If you have any entries starting with an equals sign, these are
probably the cause of your problem. Ensure that all events that you expect
to execute VBA code in an event procedure have the text [Event Procedure]
instead.
 

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