Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Run VB Code via macro

Posted on 2011-09-09
4
Medium Priority
?
490 Views
Last Modified: 2012-05-12
So I am creating a menu (customizing toolbars) in Access 2003 and I want to create a menu command to run a few lines of VB Code. Is there a way to do this in Access 2003? For example, create a module with the VB coding then create a macro that will run the module?

Thanks,
Dan
0
Comment
Question by:filtrationproducts
[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
  • 2
  • 2
4 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 36510523
the VB code that you need to run must be placed in a function in a regular module.

in the Action of your macro, you will place

RunCode


Function Name   myFunction()
0
 
LVL 1

Author Comment

by:filtrationproducts
ID: 36510777
I created a new module called newcpar and put the code in it. I then created a new macro and used RunCode with myFunction(newcpar) but it is not working.

Am I going about this right?

Dan
0
 
LVL 1

Author Closing Comment

by:filtrationproducts
ID: 36510806
I didn't know I had to give it a function name inside the module. It works now.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36510816
<Am I going about this right?> gues Not

what is the name of the function that you placed in the module "newcpar" ?
0

Featured Post

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
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, when working with VBA, learn some techniques for writing readable and easily maintained code.
Suggested Courses

688 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