Topics Search

Return macro name from a table in VBA

Return macro name from a table in VBA
Views: 1
I am builing a reporting database where I have a form(Report Dashboard) that has an unbound control where the control source is a table (Reports) and reflects the report name from the table. The table has the report name and another field called Trigger that has the name of the macro to run. When user selects the Report Name from the unbound control (ie on click) I am trying to build a VBA code that runs the macro in the field Trigger from the Reports table. Here is what I have cobbled together but I get an compile error stating "object required" on my set command for strMacro.

Private Sub lstReports_Click()
Dim myDb As DAO.Database
Dim strMacro As String

Set myDb = CurrentDb()
Set strMacro = myDb.OpenRecordset("SELECT Trigger FROM Reports")

DoCmd.RunMacro "strMacro"

On Error GoTo strTrigger_Error

Exit Sub

MsgBox "An error has occured - no associated macro."
Resume strTrigger_Done
Sponsored Links:

Similar posts...


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

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.

Update table via VBA code

Update table via VBA code Icon
Have a table (several hundred entries) which must be updated weekly using VBA code. I know how to write the actual VBA code (for each record) but I do not know how/where/what is necessary to open the table, read each record seq and update based on VBA code (function call return value) and to finally close table.

Macro from Access 2007 Ribbon: Return without GoSub

Macro from Access 2007 Ribbon: Return without GoSub Icon
I am calling a macro from a ribbon using XML. The macro calls a function to run however I keep getting the following error:
'Return without GoSub'

And then a message pops up. I have put debugger on the first line of the function, but it never gets there -therfore it must be the macro, which is a simply a RunCode macro calling the function.

Jump Start VBA Skills with MS Access Macros

Jump Start VBA Skills with MS Access Macros Icon
Macros help to speed up the performance of certain repetitive tasks when using an application. They are used extensively in all office-related software. As a programmer, you can leverage the built-in macro object in MS Access to get a head start in understanding VBA. This article explains how. TOC: Jump Start VBA Skills with MS Access Macros; Creating and running a macro in MS Access: opening the macro designer; Creating the first macro; Converting this macro to VBA code; Creating the second macro.

Collating Return Data

Collating Return Data Icon
I am in the process of collating & quantifying customer return data, and have a table that I am entering return information (i.e. Return Date, Return Code (reason for the return), $ of the Return, etc...) What I would like is to compile this data into a table that has the monthly totals based on the Return Code (so, I will end up with one column for each return code). I will then use this table to create a chart (I know how to do the chart, but need help compiling the data).

Creating a Validation Rule in an Access Table

Creating a Validation Rule in an Access Table Icon
The validation rules use the same logical expressions that can be found typically in criteria of a query and must return a logical value of either TRUE or FALSE in order to accept or reject the value and trigger an exception (validation text property). This simple property is easier to apply than attaching a macro or VBA code to an event which means learning VBA programming!

Querying a table to return duplicate values

Querying a table to return duplicate values Icon
seriously I need help with a table and form. In short I want to know if I can modify a query to return all duplicates but only if it matches a combo box entry if so can I then have the query add the matching data to the same table?
I have a table of customer names and a macro to run a query to find duplicate names from my table after update. I just don't want to keep typing all the details when they are already there basically. So say Mike called and on my form I typed mike into the combo box instead of all the duplicates appear Can I modify it to show only customers called mike?


Oh btw I don't now anything about sql or vba and would be really appreciative of any help given.

Access table valued function equivalent

Access table valued function equivalent Icon
I'm hoping someone can put me in the right direction. I have a C# app that uses access as the DB. I have some vba code that will create a table and populate it with some data. I now need a way to call the function and select from the new table externally.

I'm still relativly new to programming in vba but as far as I know you can't call a vba functional from outside the database. What I'm hoping for is some way I can select all from the function and have the function return a table, the same as table valued functions in MSSQL. e.g. SELECT * FROM myFunction()

Is this possible in assess? what would I need to do to my function to have it populate and return a table? I'm not trying to be spoon feed here, I'm just a little lost for direction. If someone can point me the right way I'm happy to do more resarch myself.

VBA Code for buttons, Access 2010

VBA Code for buttons, Access 2010 Icon
In using this new version of Access, I have found that when creating buttons, Access no longer uses vba codebehind to handle all the dirty work - rather, it seems Microsoft is forcing me to use the upgraded (and very nice I must say) Macro builder.

This is fine for all the simple tasks, but what I have myself into is a little more complex than the Macro builder is ready tohandle I think.

Before, when I created a button, not a Macro. I am trying to build the following button types:

Button 1 - Update a Field in a table, Save form, Close form
Button 2 - Update a field in a table, save form, new record
Button 3 - Update a field in a table, save form, print report, close form . and so on and so forth.

I used to put 3 or 4 buttons on the form, then copy and paste the generated vba in the correct order in a single button, and delete the dummy buttons. But now it seems as the basicfunctions are built using an embedded macro, and when that is combined with VBA, Access must choose between one or the other, rendering my button useless.

Is there a setting in 2010 that will change the way buttons are created in that VBA is used by default instead of macros?