Buckmaster
New member
- Local time
- Today, 14:39
- Joined
- Apr 29, 2010
- Messages
- 6
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
strTrigger_Done:
Exit Sub
strTrigger_Error:
MsgBox "An error has occured - no associated macro."
Resume strTrigger_Done
End Sub
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
strTrigger_Done:
Exit Sub
strTrigger_Error:
MsgBox "An error has occured - no associated macro."
Resume strTrigger_Done
End Sub