Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Call VBA script in Access 2003

Posted on 2011-09-16
11
Medium Priority
?
484 Views
Last Modified: 2012-05-12
Hello,

I've potentially missed something really straightforward here but:

How can I assign a VBA script ("macro1") to a custom toolbar button in Access 2003?

I can do it in Excel no problem, but Access seems to only list the macros created using the GUI, rather than those created using the VBA editor.

Thanks

Josh
0
Comment
Question by:bedsingar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 3
11 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 1600 total points
ID: 36549349
In the customize windows, use the 'On Action' property of the button in question and simply type the name of the function into the textbox like so:

YourFunctionName()
0
 
LVL 61

Expert Comment

by:mbizup
ID: 36549411
I don't have a copy of Access 2003 on hand at the moment (we have upgraded to 2007), but as I recall the On Action property for command bar controls had an associated list of Macros that automatically showed in a drop-down list.

This listing does not include your VBA functions - you simply have to know the name of the function needed and type it into the On Action property as I described in my last comment.
0
 

Author Comment

by:bedsingar
ID: 36549456
On another note ... I've just realised that there isn't a 'custom button' in the customise toolbar menu. -Which would make this alltogether more difficult!

I'll set up a form and try suggestion on there.

Thanks

Josh
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 61

Expert Comment

by:mbizup
ID: 36549481
<<I've just realised that there isn't a 'custom button' in the customise toolbar menu.>>

Do you mean a blank button that you can apply your own image, action etc to?

That definitely does exist...

0
 

Author Comment

by:bedsingar
ID: 36549525
Yes I do,

But normally (And In XL) you would ...

Right click tool bar
click customize
goto macros
to find the custom button command

However clicking all macros in Access just lists macros created with the GUI, and not a custom button
... any ideas where it may be hiding?
0
 
LVL 11

Assisted Solution

by:datAdrenaline
datAdrenaline earned 400 total points
ID: 36549543
>> On another note ... I've just realised that there isn't a 'custom button' in the customise toolbar menu. <<

That is not true.  You can add all the custom buttons you want.  I, like mbizup, does not have A2003 on hand at the moment, but if I recall correctly, the custom button is under the File option when creating toolbars through the interface provided in A2003.  If you cannot find it, you can create one programmatically with some 'one time use' code, or just have your app build your toolbar programmatically at every application start.

Also, it is important to know that mbizup was quite literal when she used the term "Function".  The code you want the OnAction property to call has to be declared as Function ... not a Sub ...
0
 
LVL 61

Expert Comment

by:mbizup
ID: 36549573
<< the custom button is under the File option >>

My grey cells are pretty old, so I didn't want to actually say that :-)

But now two of us remember it being under the File option.

That gives me a lot more confidence!
0
 
LVL 11

Expert Comment

by:datAdrenaline
ID: 36549682
>> My grey cells are pretty old <<

... I forget ... what were we talking about? ... hmmm ... it had to be regarding what one of my 9 kids were doing ... :) ...

Its pretty bad when I the term "kid" in my house represents a unit of time equal to two years as well as my offspring LOL!
0
 
LVL 11

Expert Comment

by:datAdrenaline
ID: 36549697
Oh yes ... the OnAction property ... One more thing to remember, the Function must be declared as Public in a Standard Module that does not share its name with the Function name.
0
 

Author Comment

by:bedsingar
ID: 36549713
Thanks Both,

It's now all clicked into place ... I was trown by the custom button not having the smily face image!

Works a treat - Ta.

Josh
0
 
LVL 61

Expert Comment

by:mbizup
ID: 36549728
Glad to help out!

< what one of my 9 kids were doing >

Time to update your profile... That ninth has been 'on the way' for far too long :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question