I’m not sure I understand why you need the CommandBars function at all. What you are trying to do will work, if you simply have a combo box with the list of reports in it. Once the Custom Print or Preview button is pressed, your code will work if you:
[li] change “CommandBars(“tlbReports”).Value” to “cboReport.text”[/li][li] add “cboReport.SetFocus” just before you try to read the text property.[/li][/ul]
If you have to use the CommandBars function for some other reason, let me know why and I’m sure we can figure something out.
I’d already tried several variations of what you suggested with no luck.
But reading your point #2 really got the 'ol brain churning and I had it working pretty quickly… the answer was quite simple… I’d been using numbers instead of just putting the name of the control!
here’s a snipit of the code involved
Dim strReportName As String
Select Case strFormName
strReportName = CommandBars("tlbBatchShipment").Controls("Report List").text
If IsNull(strReportName) Or Len(strReportName) = 0 Then
MsgBox "Please Select A Report To Preview"
DoCmd.OpenReport strReportName, acViewPreview
Oh BTW, tlb standfor TOOLBAR… I would have picked something a bit different from the Table prefix, but it was already done…
Seriously though, I’m glad that I could help you, even if only a little bit. Part of the programmer’s creed is to always try to help another programmer in need. Just remember to do the same some day for a future newbie.