I have a combo box that allows me to preview 3 different reports before I print them. This is fine but on one of the reports I would like to preview individual records and print those. I have been able to accomplish this using a comand button but would like to do it using the combo box. I am a complete novice at Access and VB but by using this forum and basiclly copying code from here and there I have been able to set up what I have so far. I set up the original combo box using a macro from a template on Microsoft office and then converted it to VB. This is what I got:
Private Sub cboReports_AfterUpdate()
Dim dbs As Database
Set dbs = CurrentDb
Dim ctr As Container
Dim cboList As String
Dim doc As Document
cboList = ""
Set ctr = dbs.Containers("Reports")
'build the value list for Reports
For Each doc In ctr.Documents
Debug.Print doc.Name
cboList = cboList & doc.Name & ";"
Next
'Load the Combo Box box
cboList = Left(cboList, Len(cboList) - 1) 'truncate the last semicolon
cboReports.RowSourceType = "Value List"
cboReports.RowSource = cboList
End Sub
And this is the code I used for the comand button that does what I want to do for the one report in the combo box:
DoCmd.OpenReport "rptName", acViewPreview, , "id = " & Me!ID
How can I combine the two if at all possible?
Thanks for any help in advance.
Private Sub cboReports_AfterUpdate()
Dim dbs As Database
Set dbs = CurrentDb
Dim ctr As Container
Dim cboList As String
Dim doc As Document
cboList = ""
Set ctr = dbs.Containers("Reports")
'build the value list for Reports
For Each doc In ctr.Documents
Debug.Print doc.Name
cboList = cboList & doc.Name & ";"
Next
'Load the Combo Box box
cboList = Left(cboList, Len(cboList) - 1) 'truncate the last semicolon
cboReports.RowSourceType = "Value List"
cboReports.RowSource = cboList
End Sub
And this is the code I used for the comand button that does what I want to do for the one report in the combo box:
DoCmd.OpenReport "rptName", acViewPreview, , "id = " & Me!ID
How can I combine the two if at all possible?
Thanks for any help in advance.
Last edited: