Solved

Converting Macro to VBA? Can you convert back?

Posted on 2008-10-11
4
1,233 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
  • 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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now