Oops, watch for word-wrap.
The lines
ListReports =
CurrentDb().Containers("Reports").Documents(lngRow).Name
should be a single line of text, as should
ListReports =
CurrentDb().Containers("Reports").Documents(lngRow).Properties("Description")--Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele(no e-mails, please!)"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in messageuse the following function. (You set the RowSourceType property toListReports, and leave the RowSource property blank)>> Function ListReports( _> lstListbox As Control, _> varID As Variant, _> lngRow As Long, _> lngCol As Long, _> intCode As Integer _> ) As Variant>> On Error GoTo Err_ListReports>> Select Case intCode> Case acLBInitialize> ListReports = True> Case acLBOpen> ListReports = Timer> Case acLBGetRowCount> ListReports = CurrentDb().Containers("Reports").Documents.Count> Case acLBGetColumnCount> ListReports = 2> Case acLBGetColumnWidth> Select Case lngCol> Case 0> ListReports = 2800> Case 1> ListReports = 2800> Case Else> ListReports = 0> End Select> Case acLBGetValue> Select Case lngCol> Case 0> ListReports =CurrentDb().Containers("Reports").Documents(lngRow).Name> Case 1> ListReports =CurrentDb().Containers("Reports").Documents(lngRow).Properties("Description")> Case Else> ListReports = vbNullString> End Select> End Select>> End_ListReports:> Exit Function>> Err_ListReports:> ' Error 3270: Property not found.> ' This means that there isn't a description associated with the report.> ' In that case, we want to return an empty string and continue.> If Err.Number = 3270 Then> ListReports = vbNullString> Resume Next> Else> Err.Raise Err.Number, "ListReports", Err.Description> Resume End_ListReports> End If>> End Function>>>> --> Doug Steele, Microsoft Access MVP>
http://I.Am/DougSteele> (no e-mails, please!)>>> "David Newmarch" <
[email protected]> wrote inmessage Thanks Jerry.>>>> This successfully gives me a listbox listing all the reports by name, but>> how would I extend the sql query to include a column that gives thereport>> Captions as well? The report names in my database are naming conventionnames>> like "rptProposalsByCategory" and I'd like to show the captions insteadwhich>> are in plain English.>>>> "Jerry Whittle" wrote:>>>>> SELECT MSysObjects.Name AS ReportName>>> FROM MSysObjects>>> WHERE (((MSysObjects.Type)=-32764))>>> ORDER BY MSysObjects.Name;>>> -->>> Jerry Whittle, Microsoft Access MVP>>> Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.>>>>>> "David Newmarch" wrote:>>>>>> > In a database which contains a variety of possible reports is there away to>>> > create something like a list box (on a form) showing an updated listof all>>> > available reports from which the user can select which report to view?>>> >>>> > I really want something equivalent to a kind of scaled down version ofthe>>> > Database Window, without actually having to allow the user to view the>>> > Database Window itself, and I can't quite figure out how to approachthis.>>> >>>> > Is there a way to have a field in a table or query that is populatedby all>>> > available ReportNames (or ReportCaptions, better still)?>>