1.

Solve : Microsoft Access: Code for list boxes?

Answer»

I'm using a list BOX to open queries. It is working just fine but now I need to add reports. How do I adapt the following code to accommodate queries and reports? Thanks, in ADVANCE, for any help.

Dim DocName As String

DocName = Me!ReportsList.Column (0)
'Used to TELL which report it is.
QueryName = ReportsList.Column (2)
DoCmd.OpenQuery DocName

Exit Sub
End SubI take it the Me!ReportsList is the list box object?

and this list box has a row SOURCE of?

Are you planning on putting queries and reports in the same list box? If so you are going to have to know the object type and do an "if" or "case" statement based on the type.

DoCmd.OpenQuery DocName
or
DoCmd.OpenReport DocName



Discussion

No Comment Found