Error when macro is called

J

jAdams

Hi,

Please Help

I am working with an Access database that was developed using Office 97 and
was converted to the 2002-2003 Access file format. On this one form there
are 26 text boxes (representing yearly pay periods) and on the “On Lost
Focus†event for each text box the person who developed it set it to run a
macro (that person is since long gone so I'm stuck with this now). The macro
simply calls a function to validate the data that was just entered in the
text box.

When the On Lost Focus event triggers I get this error msg:

“You’ve tried to run a Visual Basic Procedure to set a property or method
for an object. However, the component doesn’t make the property or method
available for Automation operations.

Check the component’s documentation for information on the properties and
methods it makes available for Automation operations.â€

From what I can tell the process errors out before it even makes it to the
function i.e. there is nothing wrong with the code in the function. I tested
this by placing a break at the beginning of the function and the process
never reaches that point before the error occurs.

Also when testing I changed the macro call to an Event Procedure and just
called the function from the event with VBA. This seemed to work but I
believe it’s silly to have to add an event procedure for each text box (26 of
them) to call this function and I can’t help thinking there has got to be a
simple solution, something I’m obviously missing.

The only thing I can figure is that perhaps I need to add or change a
Reference (under Tools – References) but if I am correct I can not figure out
what Reference I need to change/add.

If anyone knows what the problem with this is and/or can point me in the
right direction it would be greatly appreciated.

Thanking you in advance

J. Adams
 
J

jAdams

Hi Steve,

The macro calls a function that simply tests the value entered/edited. The
function it calls accepts no arguements and returns nothing (why the person
who created it used a function and a macro to call it is beyond me but it has
worked up until now so whatever).

The function called from the macro is named EditPayPeriod and it asks the
user a question on the type of calculation method that is to be used on that
value. From this it sets a boolean value and then calls another function
that accepts this value and based on it will check/uncheck a textbox (hidden
to the user) that is used to determine the calulation method used on the
value that was entered.

No calulations are done at this point; the check box us simply used as a
flag that will be tested at a later time when another seperate event occurs.

I forgot to mention the first line in the error message displayed which
reads: "The object doesn't contain the Automation object "EditPayPeriod".

Other that that it seems like a pretty unremarkable function that doesn't do
anything I haven't seen before. So it's kind of got me stumped.

I hope this helps futher describes the situation.

Thanks for the reply Steve.
 
S

Steve Schapel

jAdams,

Ok, reading between the lines here, I guess the macro includes a RunCode
action. Am I right? If so, I believe the Function Name argument in the
macro *must not* be preceded by a = and *must* include parentheses at
the end. In other words, it should look like this...
EditPayPeriod()
 
J

jAdams

Hi Seve,

Yup, that was the problem, no brackets after the function name. Excuse me
while I kick myself in the head a few times for missing that.

I have used macros to call functions in before so I do know that's how you
call functions from macros. I definitely looked at the call in the macro in
question (many times) but in my haste/frustration I failed to notice the
missing brackets.

It was one of those: right in front of my eyes but I can't see the forest
through the trees scenarios. Kind of like when you can't figure out why a
program won't compile and the person next to you has a look and 3 seconds
later they say to you, "You forgot the End If statement you moron!!"

I guess because I didn't develop it I thought the person who did could have
messed up an umpteen number of things with the app. I was tearing apart the
tranny but failed to notice it was out of gas. Excuses, excuses...

Anyway, thanks for the slap upside the head, I appologize for my stupididty.

You help was greatly appreciated.

JA
 

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