Solved

Converting Macro to VBA? Can you convert back?

Posted on 2008-10-11
4
1,289 Views
Last Modified: 2012-05-05
Hello,

I created a macro using the Access GUI, but then I wanted to add some extra code. So I selected the option 'Convert Macros to Visual Basic'. This was great as it allowed me to add some extra code snippets. But in the process it converted my macro into a module.

1) Am I able to convert this module back to a macro?
2) Can I run module's like macros?
0
Comment
Question by:Dozingquinn
[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 8

Expert Comment

by:Emil_Gray
ID: 22696103
I wouldn't worry about converting a module to a macro. Yes you can. What exactly is the code you are using to call the macro/module?
0
 

Author Comment

by:Dozingquinn
ID: 22696431
Hi Emil,

Below is the code snippet. The reason that I ask whether I can convert the module back to a macro, is because I don't know how to use (or run) modules. I only converted the macro to Visual Basic code so I could add in some more parameters that weren't visible in the Access Macro GUI.

Is there a way to look into the VB code of a macro without converting it into a module?

'------------------------------------------------------------
' mac_excel_patient_export
'
'-
Function mac_excel_patient_export()
On Error GoTo mac_excel_patient_export_Err
 
    DoCmd.TransferSpreadsheet acExport, 10, "qry_excel_patient", "C:\data.xls", True, "Patientsheet"
DoCmd.TransferSpreadsheet acExport, 10, "qry_excel_treatment", "C:\data.xls", True, "Treatmentsheet"
 
mac_excel_patient_export_Exit:
    Exit Function
 
mac_excel_patient_export_Err:
    MsgBox Error$
    Resume mac_excel_patient_export_Exit
 
End Function

Open in new window

0
 
LVL 8

Accepted Solution

by:
Emil_Gray earned 400 total points
ID: 22696660
What is the code you use to call the macro? Is it a button? At any rate all you need do is substitute the name of the Function where you are calling the Macro. For instance:
Call mac_excel_patient_export
That code will run the function. You may not even need to use the key word "Call" but I'm not sure about that.
0
 

Author Closing Comment

by:Dozingquinn
ID: 31505385
Thanks Emil. I ended up attaching the 'basic' version of the macro to a button - then I viewed the code of the macro and ended up making the alterations there. It was a kind of 'the long way around' but it worked.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

696 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