Visual Basic

B

barbapapa

I have access 2002. I have problems running code from the visual basic
window, when I press go or hit F5 a window titled "Macros" open instead
waiting for a macro name form the user. Can somebody tells me what I'm
doing wrong. Thanks.
 
6

'69 Camaro

Hi.

Are you attempting to run a procedure that requires parameters to be passed
to it? If you don't pass the parameters, then the Macros dialog window will
be displayed. To run this procedure with <F5>, the Run menu, or the "Run"
button, you'll need to run another procedure that doesn't require parameters
that calls this procedure and supplies the required arguments.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
 
B

barbapapa

Thanks for replying. It looks like the macro dialog window shows up on
almost anything I run. I say almost because I just tried msgbox "hello" and
it works fine but if I try

Private Sub Form_Current()

If IsNull([id]) Then

Command2.Enabled = False

Command3.SetFocus

Else

Command2.Enabled = True

End If

End Sub

I get the macro dialog window. Is it because it can only be run when the
form is current (in this example)
 
6

'69 Camaro

Hi.
I get the macro dialog window. Is it because it can only be run when the
form is current (in this example)

No. It's because the code is in a class module, not a standard module.
Class modules aren't exposed in quite the same way as a standard module.
You'll get the Macros dialog window when attempting to run a procedure in a
class module from the VB Editor in Access 2000 and later verssions, even
when there are no parameters to pass.

The simplest way I have found to test procedures in class modules is to add
a command button to the form that has an OnClick( ) event that contains code
that calls the relevant procedure in the class module, then put the form in
Form View and click the button to run the code. Breakpoints can be added as
needed so that the code can be stepped through during debugging.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)


barbapapa said:
Thanks for replying. It looks like the macro dialog window shows up on
almost anything I run. I say almost because I just tried msgbox "hello" and
it works fine but if I try

Private Sub Form_Current()

If IsNull([id]) Then

Command2.Enabled = False

Command3.SetFocus

Else

Command2.Enabled = True

End If

End Sub

I get the macro dialog window. Is it because it can only be run when the
form is current (in this example)

message news:%[email protected]...
Hi.

Are you attempting to run a procedure that requires parameters to be
passed
to it? If you don't pass the parameters, then the Macros dialog window
will
be displayed. To run this procedure with <F5>, the Run menu, or the "Run"
button, you'll need to run another procedure that doesn't require
parameters
that calls this procedure and supplies the required arguments.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
 

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