By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,225 Members | 1,434 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,225 IT Pros & Developers. It's quick & easy.

Run Report Form Combo Box

P: 6
I am trying to run a specific report from a combo box list. I typed in the report names my self to the list. I went to onclick and provided the following code:

Private Sub Report_Click()
DoCmd.OpenReport "Modification Monitoring Report", acViewReport
DoCmd.OpenReport "Special Servicing Loan Performance Report", acViewReport
End Sub

I need to be able to only open the report chosen by the drop down? Please help.
Jan 5 '12 #1
Share this Question
Share on Google+
3 Replies


ADezii
Expert 5K+
P: 8,679
  1. Assuming a Combo Box named cboReports, populate cboReports with the Names of all Reports in the Database. Here, I chose to have this done in the Form's Open() Event.
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Form_Open(Cancel As Integer)
    2. Dim obj As AccessObject
    3.  
    4. With Me![cboReports]
    5.   .RowSourceType = "Value List"
    6.  
    7.    For Each obj In CurrentProject.AllReports
    8.      .AddItem obj.Name
    9.    Next
    10. End With
    11. End Sub
  2. Open the Selected Report in Preview Mode. This should be done in the AfterUpdate() Event of cboReports as indicated below.
    Expand|Select|Wrap|Line Numbers
    1. Private Sub cboReports_AfterUpdate()
    2. If IsNull(Me![cboReports]) Then Exit Sub
    3.  
    4. DoCmd.OpenReport Me![cboReports], acViewPreview, , , acWindowNormal
    5. End Sub
Jan 5 '12 #2

P: 6
I chose to have this done in the Form's Open() Event? Where do I do this? int he combo box's properties?
Jan 5 '12 #3

ADezii
Expert 5K+
P: 8,679
Open Form in Design View ==> View ==> Properties ==> Select the Event Tab ==> On Open
Jan 5 '12 #4

Post your reply

Sign in to post your reply or Sign up for a free account.