Hello,
This may be a bit complicated, so please let me know if I am taking the correct route to accomplish this.....basically I have an Access Database with a main menu form that has a dropdown box to allow the user to make a selection which stores into a field in a table. Based on the data in the field (there are only 4 possible selections), I would want to trigger a macro I created to run a report (I have a separate macro created for each of the 4 reports as well). I started creating a module and have tried the following code which is obviously erroneous, but you may be able to better understand where I am going with this is I share it:
Sub
If strField = "Line Selection" strTable = "Main Menu Line Selection"
Main Menu Line Selection.Line Selection = HT6
Then DoCmd.RunMacro "Run HT6_AGGREGATE Report"
ElseIf strField = "Line Selection" strTable = "Main Menu Line Selection"
Main Menu Line Selection.Line Selection = HT8
Then DoCmd.RunMacro "Run HT8_AGGREGATE Report"
ElseIf strField = "Line Selection" strTable = "Main Menu Line Selection"
Main Menu Line Selection.Line Selection = HTFL
Then DoCmd.RunMacro "Run HTFL_AGGREGATE Report"
ElseIf strField = "Line Selection" strTable = "Main Menu Line Selection"
Main Menu Line Selection.Line Selection = SDFL
Then DoCmd.RunMacro "Run SDFL_AGGREGATE Report"
End If
End Sub
This may be a bit complicated, so please let me know if I am taking the correct route to accomplish this.....basically I have an Access Database with a main menu form that has a dropdown box to allow the user to make a selection which stores into a field in a table. Based on the data in the field (there are only 4 possible selections), I would want to trigger a macro I created to run a report (I have a separate macro created for each of the 4 reports as well). I started creating a module and have tried the following code which is obviously erroneous, but you may be able to better understand where I am going with this is I share it:
Sub
If strField = "Line Selection" strTable = "Main Menu Line Selection"
Main Menu Line Selection.Line Selection = HT6
Then DoCmd.RunMacro "Run HT6_AGGREGATE Report"
ElseIf strField = "Line Selection" strTable = "Main Menu Line Selection"
Main Menu Line Selection.Line Selection = HT8
Then DoCmd.RunMacro "Run HT8_AGGREGATE Report"
ElseIf strField = "Line Selection" strTable = "Main Menu Line Selection"
Main Menu Line Selection.Line Selection = HTFL
Then DoCmd.RunMacro "Run HTFL_AGGREGATE Report"
ElseIf strField = "Line Selection" strTable = "Main Menu Line Selection"
Main Menu Line Selection.Line Selection = SDFL
Then DoCmd.RunMacro "Run SDFL_AGGREGATE Report"
End If
End Sub