Quirk in Access where 1 code error = "The expression On Load you entered as the ... (1 Viewer)

MartyL354

MartyL
Local time
Today, 13:22
Joined
Jan 12, 2009
Messages
14
Quirk in Access where 1 code error = "The expression On Load you entered as the ...

I ran across a particularly frustrating quirk in Access 2007 (perhaps other versions also).

After saving changes to code and reopening the form I was working on I kept getting the following general errors:

"The expression On Load you entered as the event property setting produced the following error: Expected Sub, Function or Property"

"The expression On Activate you entered as the event property setting produced the following error: Expected Sub, Function or Property"

"The expression On Got Focus you entered as the event property setting produced the following error: Expected Sub, Function or Property"

The same errors would occur everytime I reopened the form. I had code in the On Load and On Activate events but nothing in the On Got Focus event (the On Got Focus event in the Property Sheet was blank also)

I commented out all of the code in the On LOad and On Activate events and still got the same errors.

I had changed a good bit of code in a number of places on this form so I finally had to comment out all of the code in every event and uncomment them one event at a time until I found the offending code.

It turned out to be in the Click event of one of the command buttons. The line was: intMins CInt(cmbSaleTime_mins.Value)

Which should have been: intMins = CInt(cmbSaleTime_mins.Value)

Has this problem been corrected in any patches or anything? If not, does anyone know any way to stop it?

Thanks,

Marty
 

MartyL354

MartyL
Local time
Today, 13:22
Joined
Jan 12, 2009
Messages
14
Re: Quirk in Access where 1 code error = "The expression On Load you entered as the .

jal sent me a solution to this issue. (Thanks jal)

I know that the error would finally surface once I ran the event where the error was but the fact that Access detected an error, in my opinion, it should show you where the error occurs.

What jal found was that if you select the Debug menu inn the Code window and select the Compile (the name of your project) option Access goes immediately to the offending line of code.

This is actually better than having to wait for the event with the problem to run.
 

MartyL354

MartyL
Local time
Today, 13:22
Joined
Jan 12, 2009
Messages
14
Re: Quirk in Access where 1 code error = "The expression On Load you entered as the .

Caveat. This is at leat the case in Access 2007.
 

boblarson

Smeghead
Local time
Today, 10:22
Joined
Jan 12, 2001
Messages
32,059
Re: Quirk in Access where 1 code error = "The expression On Load you entered as the .

Caveat. This is at leat the case in Access 2007.

Works the same way in all versions of Access.
 

MartyL354

MartyL
Local time
Today, 13:22
Joined
Jan 12, 2009
Messages
14
Re: Quirk in Access where 1 code error = "The expression On Load you entered as the .

Thanks for the info Bob.
 

kriswork

Registered User.
Local time
Today, 18:22
Joined
Jul 11, 2011
Messages
21
Re: Quirk in Access where 1 code error = "The expression On Load you entered as the .

Using Access 2003 and getting same errors.
Strangely, If I relinked the tables to the backend (even though they were fine) it fixed the problem until I shutdown Access and reloaded the database when the problem then reappeared.
Thanks to Jal's suggestion I compiled the project and fixed a couple of things which were in another procedure unrelated to the front screen loading and had been there for months without causing any problems.
Interestingly, what the compiler said to fix on one machine was completely different to a different machine with the same database (I develop on 1 machine and run live on another).

Thanks all.

Kristian
 

Fat

New member
Local time
Today, 11:22
Joined
Jul 25, 2011
Messages
4
Re: Quirk in Access where 1 code error = "The expression On Load you entered as the .

So I have this problem, but I have no problems with the compile and it just started for no reason at all. How can I fix this?
 

kriswork

Registered User.
Local time
Today, 18:22
Joined
Jul 11, 2011
Messages
21
Re: Quirk in Access where 1 code error = "The expression On Load you entered as the .

Hi Fat,

Create a blank database and then copy over everything from the problem database to the new blank database bit by bit , i.e. all the forms, all the queries, all the tables etc and that might help.

Kris
 

Fat

New member
Local time
Today, 11:22
Joined
Jul 25, 2011
Messages
4
Re: Quirk in Access where 1 code error = "The expression On Load you entered as the .

Wow... this is a split 3MB database with no data in it (65MB with data). I think I need to put this guy in SQL server and create a C# web front end (and I have no idea how to program in C#). If this guy dies on me we are screwed. It'll take me months to put this guy in the web; there are over 4,000 lines of code for just the 2 main access forms. This will take a week just to get this guy transferred. I guess there isn't much I can do. So sick of this.
 

Users who are viewing this thread

Top Bottom