View Reports
Hi, There a couple of different way you could do this and I have put two lots of VB code below that you can modify and use. Firstly you create the Combobox list by choosing the option that you will type the values yourself, you then type in all your report names on each line. After that you can then go to the VB code editor and paste my code in and modify it by changing my report names, (Customers) etc to your report names. Make sure you choose the Combobox and the On_Click option in the VB editor to paste the code into. I like the first method better which checks the value of the Combobox and then opens the corrosponding report in the maximised form. The second method does the value check before running an assigned macro to open each report. With this you must first assign macros to each report in Access. Remember each of these bits of code must be placed between the "Private Sub" heading and the "End Sub" ending, and change the "Combo23" name to reflect your combobox too. If you need a hand just email me.
First Method
If Combo23.Value = "Customers" Then
DoCmd.OpenReport "Customers", acViewPreview, acWindowNormal
DoCmd.Maximize
ElseIf Combo23.Value = "Customers 1" Then
DoCmd.OpenReport "Customers1", acViewPreview, acWindowNormal
DoCmd.Maximize
ElseIf Combo23.Value = "Customers 2" Then
DoCmd.OpenReport "Customers2", acViewPreview, acWindowNormal
DoCmd.Maximize
End If
Second Method
If Combo23.Value = "Customers" Then
DoCmd.RunMacro "Macro1"
DoCmd.Maximize
ElseIf Combo23.Value = "Customers 1" Then
DoCmd.RunMacro "Macro2"
DoCmd.Maximize
ElseIf Combo23.Value = "Customers 2" Then
DoCmd.RunMacro "Macro3"
DoCmd.Maximize
End If
×