Button in toolbar that runs vba code

E

Erwin Bormans

Hey all,

I'm trying to add a button to a toolbar in MS Access 2007 and by clicking
that button let him to run some own written vba code.

But I cant find an option to write vba code behind a button.

I've tried to make a macro that runs a procedure, but I get the error all
the time that Access cant find that procedure...

Made a module called Email:
Option Compare Database

Public Function email()
mail
End Function

Public Sub mail()
MsgBox "test"
End Sub

And then make a macro that runs email()

Can somebody help me in the right direction?

Kind regards,
Erwin
 
K

Keven Denen

Hey all,

I'm trying to add a button to a toolbar in MS Access 2007 and by clicking
that button let him to run some own written vba code.

But I cant find an option to write vba code behind a button.

I've tried to make a macro that runs a procedure, but I get the error all
the time that Access cant find that procedure...

Made a module called Email:
Option Compare Database

Public Function email()
    mail
End Function

Public Sub mail()
    MsgBox "test"
End Sub

And then make a macro that runs email()

Can somebody help me in the right direction?

Kind regards,
Erwin

If you want to execute VBA code from a macro, you need to use the
RunCode option. Is this what you are using on your macro?

Keven Denen
 
K

Keven Denen

Hey all,

I'm trying to add a button to a toolbar in MS Access 2007 and by clicking
that button let him to run some own written vba code.

But I cant find an option to write vba code behind a button.

I've tried to make a macro that runs a procedure, but I get the error all
the time that Access cant find that procedure...

Made a module called Email:
Option Compare Database

Public Function email()
    mail
End Function

Public Sub mail()
    MsgBox "test"
End Sub

And then make a macro that runs email()

Can somebody help me in the right direction?

Kind regards,
Erwin

On second thought, if all you are trying to do is run the VBA code,
skip the macro altogether.

When you go into the customize screen for adding the button, click the
File category and drag the very first option under Commands (Custom)
to the toolbar. Right click on the new button, choose Properties, in
the On Action property put in the name of your procedure (the
procedure must be public).

Keven Denen
 
E

Erwin Bormans

Im working with a dutch version unfortunally.

But anyway in the macro editor i find 2 actions i can choose from:
RunProcedure and RunAssignment

But I cant get either one to work...

Kind regards,
Erwin


"Keven Denen" <[email protected]> schreef in bericht
Hey all,

I'm trying to add a button to a toolbar in MS Access 2007 and by clicking
that button let him to run some own written vba code.

But I cant find an option to write vba code behind a button.

I've tried to make a macro that runs a procedure, but I get the error all
the time that Access cant find that procedure...

Made a module called Email:
Option Compare Database

Public Function email()
mail
End Function

Public Sub mail()
MsgBox "test"
End Sub

And then make a macro that runs email()

Can somebody help me in the right direction?

Kind regards,
Erwin

If you want to execute VBA code from a macro, you need to use the
RunCode option. Is this what you are using on your macro?

Keven Denen
 
E

Erwin Bormans

Thanks for all your effort.

Ive tried to find whats stated below, but i cant find the button custom and
Im not able to right click any of the buttons and go to properties.

Im working with the latest version of ms access.

Kind regards,
Erwin


"Keven Denen" <[email protected]> schreef in bericht
Hey all,

I'm trying to add a button to a toolbar in MS Access 2007 and by clicking
that button let him to run some own written vba code.

But I cant find an option to write vba code behind a button.

I've tried to make a macro that runs a procedure, but I get the error all
the time that Access cant find that procedure...

Made a module called Email:
Option Compare Database

Public Function email()
mail
End Function

Public Sub mail()
MsgBox "test"
End Sub

And then make a macro that runs email()

Can somebody help me in the right direction?

Kind regards,
Erwin

On second thought, if all you are trying to do is run the VBA code,
skip the macro altogether.

When you go into the customize screen for adding the button, click the
File category and drag the very first option under Commands (Custom)
to the toolbar. Right click on the new button, choose Properties, in
the On Action property put in the name of your procedure (the
procedure must be public).

Keven Denen
 
K

Keven Denen

Thanks for all your effort.

Ive tried to find whats stated below, but i cant find the button custom and
Im not able to right click any of the buttons and go to properties.

Im working with the latest version of ms access.

Kind regards,
Erwin

"Keven Denen" <[email protected]> schreef in bericht










On second thought, if all you are trying to do is run the VBA code,
skip the macro altogether.

When you go into the customize screen for adding the button, click the
File category and drag the very first option under Commands (Custom)
to the toolbar. Right click on the new button, choose Properties, in
the On Action property put in the name of your procedure (the
procedure must be public).

Keven Denen- Hide quoted text -

- Show quoted text -

Ah, 2007. Worthless. Sorry, not a clue how to do it in 2007.

Keven Denen
 

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