Topics Search

Run vba code from within 2010 Data Macro

Run vba code from within 2010 Data Macro
Views: 61
Is it possilbe to run a VBA function from within a 2010 Data Macro.

I have a function called WhoAmI with returns the Id of the user

I want to run this function from within the data macro
Sponsored Links:

Similar posts...


How to you tell Access 2010 to run VBA code?

How to you tell Access 2010 to run VBA code? Icon
I started with creating a Macro in Access 2010 which is very repetitious (open a query, update and close. move to next query). I used the Macro builder to make sure I got the right code commands and then converted to VBA because it is my understanding running code is better than running a macro (but I still haven't seen anything thatexplains to me why that is so).

2010 VBA "do while" code in a macro

2010 VBA "do while" code in a macro Icon
In Access 2010, want to run perform a "do while" loop in a macro. I understand VBA is the way to do this. So, I think I want to run a VBA script in a macro.

This Macro runs against a Form that has a SubFrom (MainForm named "Expense ID" & SubForm, "Expense"). Macro is initiated by pressing a button.

I would like help with some VBA code showing how to perform the following:

1. Evaluate a field ("Activity") in the first record of Subform ("Expense") against condition "Is not Null".

2. If condition is true, set value of another field ("Post") in the same SubForm record to "1".

3. Move to next record and repeat steps 1 & 2 until all Subform records are evaluated.

4. Return to macro that initiated the VBA script to perform the next action in the macro.

Run a converted Macro

Run a converted Macro Icon
I am a beginner in Access VBA. I have created a macro in access to run a make table query and then rename the table. Now I want the current date to be part of the renamed table.
So, I converted the Macro to VBA and then put the date field in the code. When I run it from the VBA editor, using F5, it runs great and produced the right output. But, when I run the original macro, it is still creating the hard coded name as in the macro.

I want to know, how to run the converted macro, without having to go into the VBA editor mode

Access 2010 now creates macros instead of VBA code

Access 2010 now creates macros instead of VBA code Icon
I have been using 2003 for a while but I have switched to 2010 recently.

I have just found out that if you use the wizards when creating a command button, Access now creates a macro instead of creating VBA code (for opening a form, for example)

I prefer code over macros, so is there a way to change this?

Also, what about the macros that have already been created? How can those be converted to VBA?.When I use the "Convert From's Macors to Visual Basic" option I get a "There was a problem opening the macro "[Embeded Macro]". Do you want to continue?" and the macro does not get converted

run VBA code in Macro

run VBA code in Macro Icon
Is it possible to run VBA code within a macro?
What I want to do is run one macro for certain days of the week and another macro for other days of the week. I could just stick the code in the button on the switchboard but I could see an overzealous user changing the switchboard and then the code is gone. I like the idea of the code within the macro itself so someone not familiar with VBA could alter it.

I tried putting something like
If Me.Today = "Monday" Then
DoCmd.RunMacro "Macro2"
ElseIf Me.Today = "Thursday" Then DoCmd.RunMacro "Macro2"
Else: DoCmd.RunMacro "Macro3"
End If

In the RunCode action of the Macro with no success.
I'm sure there is an easy fix, but I'm not seeing it.

Run a Embedded Macro from VBA Code

Run a Embedded Macro from VBA Code Icon
I am trying to rerun an embedded macro which is attached to the AfterUpdate event of a combobox. Is there anyway of rerunning this query from VBA Code?

I have tried using:


However it says you need to insert the Macro name however I do not know what the embedded macro is called in order to refer to it

Running Code based on User's Response to delete macro

Running Code based on User's Response to delete macro Icon
I am using the standard delete macro that the access button creator has. I added a line to the macro that runs a vba code segment, but I only want this to run if the user presses yes to deleting the record. Is there a condition that I can write that will allow me to determine if the user pressed yes or no and run the code accordingly?

Access 2010 Macro

Access 2010 Macro Icon
I have an MS Access 2010 Database that will be run @ 6:00 AM Automatically. The Autoexec Macro has been created. the purpose of the Macro is to update a local table with data from SQL Server. In previous versions of Access I used setwarnings = off to accomplish this without user intervention. However in MS Access 2010 I don't find that option. Anybody know where it is or how I can accomplish this

VBA to get value from combobox to run a macro

VBA to get value from combobox to run a macro Icon
How can I get vba to do this.

When I click a button on the main form the vba code will execute and get the value from the combobox ie TE4700 and locate the macro with the same name ie TE4700 with reports in then it willrun the macro and print off the reports.

Execute Excel Macro from Access failing

Execute Excel Macro from Access failing Icon
I am trying to run the code below in my access 2007 database to start an excel macro. However, I need to make some changes to it that far exceed my applicable knowledge. The changes are below:

1. The macro currently only runs correctly when Excel is not running and the Personal.XLSB workbook is closed. I need theo macro to be smart enough to open Personal.xlsb if needed, or runthe code if it is already open.

2. The Macro that is built in Excel VBA opens several workbooks makes changes to them, then closes some and leaves some open and send a couple of emails. The Access VBA closes excelcompletely and crashes if I try to remove this line


How do I keep the Access VBA from closing excel?

3. I currently have the path hardcoded to my personal.xlsb, however I need this to be able to run from any one of my colleagues computers so I would like the path to the personal.xlsb workbook be relative.