Can anyone give me some idea of how to fill a list box with the captions and names of all reports. I want to use this listbox as a selection of reports for printing.
You might be able to query the information (List of Reports) for the hidden system table MSysObjects. The "Type" field seems to have unique numeric identifiers for each type of object. The names of the reports ar also listed.
Got this from Beginning access 2000 VBA by wrox pressuseful book to have)
function listreports (fld as control, id as variant, row as variant,col as variant,code as variant)as variant
Dim objAO as accessobject
dim objCP as object
Static strReports () as string
Static intentries as integer
Select Case Code
Case acLBInitialize
intEntries= 0
Set objCP= application.currentProject
Redim strReports(objCP.allreports.count)
for each objAO in objCP.allreports
strReports(intentries)=objAO.name
Next objAO
listreports=inEntires
Case acLBOpen
listreports= timer
Case acLBGetRowCount
listreports= inEntries
Case aclbgetcolumncount
listreports=1
case aclbgetcolumnwidth
listreports= -1
case aclbgetformat
case aclbend
end select
end function
Call the function in the 'row source type' of the properties of the list box
ie Row Source Type ... listreports
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.