Solved

Run VB Code via macro

Posted on 2011-09-09
4
484 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 125 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses
Course of the Month4 days, 23 hours left to enroll

636 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