syntax 101

  • Thread starter Thread starter Roland Alden
  • Start date Start date
R

Roland Alden

I have a FormHeader_Click event handler. In the header is a text box name
nfc and when I break in the event handler my watch window will show me a
Object/Textbox for me.nfc.

I have a procedure declared as

private sub Foo (c as control)

and I'm trying to pass nfc to it inside FormHeader_Click, i.e.:

Foo(me.nfc)

However this raises an error at runtime "object required".

It's not clear to me whether my declaration of Foo is wrong or my syntax at
the call site is wrong. Or perhaps both?
 
Roland said:
I have a FormHeader_Click event handler. In the header is a text box name
nfc and when I break in the event handler my watch window will show me a
Object/Textbox for me.nfc.

I have a procedure declared as

private sub Foo (c as control)

and I'm trying to pass nfc to it inside FormHeader_Click, i.e.:

Foo(me.nfc)

However this raises an error at runtime "object required".


You've declare the procedure as a Sub but you're calling it
as a function.

The legal ways to call a Sub procedure are:
Foo Me.nfc
or
Call Foo (Me.nfc)

Note the lack of parenthesis in the first syntax. When you
places ( ) around the argument, you're telling Access to
evaluate the expression inside and pass it's value to the
procedure, shich fails because the procedure expect a
control object, not a value.
 

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

Back
Top