Question List Box

mm07nkb

Registered User.
Local time
Today, 23:27
Joined
Sep 1, 2011
Messages
23
Hi

On access 2007 I have created a modal form which I want to contain a list of my reports.

I want a button to run the report that is highlighted.

I also want a button that will run the query of the report that is highlighted.

How do I do this? I am new to access and help will be much appreciated!!
 
Create a table with 3 fields to contain the name you want the user to see, the name of the report in the database and the name of the query in the database.

Set the listbox to 3 columns, but set 2 of the column widths to 0.

Then your vba will use something like:
Code:
DoCmd OpenReport cboComboboxName.Column(1)

.Column is 0 based (i.e. 3 columns would be 0, 1 & 2) I think.
 
I have created the table with 3 columns after the primary key.
In the event on property sheet under 'onclick' I have entered the code

DoCmd OpenReport cboLISTReport.Column(1)

as my list box is called 'LISTReport'

This is highlighting this command as red and it wont work?

ANy suggestions thanks!!
 
Try changing it to a combobox (I have limited knowledge of listboxes)

Or try changing the bound column instead of specifying the column in VBA.
 
This is the vba code:


Private Sub LISTReport_BeforeUpdate(Cancel As Integer)

DoCmd OpenReport cboLISTReport.Column(1)

End Sub
 
ok that works now but it is printing the reports instead of opening them!
 
Double click OpenReport and press F1.

The help page will tell you all the different things you can set, one of which is opening the report in preview mode rather than printing it.
 
How do i change the vba so that it opens the report instad of printing the report??


Thanks!!
 
From the help page I told you to access:

expression.OpenReport(ReportName, View, FilterName, WhereCondition, WindowMode, OpenArgs)

The 1st variant is the report name which you are already doing, the 2nd is the view type. "acViewPreview" is the one you want to view the report on screen.

:edit:

Completed code:
Code:
DoCmd OpenReport cboLISTReport.Column(1), acViewPreview
 

Users who are viewing this thread

Back
Top Bottom