Visual Basic to run reports

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am not very experienced in visual basic. I am trying to open a report by
using option buttons and combo boxes. What I am trying to do is use option
buttons to specify how I want the data sorted. Then I want to use the Combo
box to pull a certain report by those criteria. I know that I am doing this
wrong and I don't know where to start.

Can someone direct me where I can start?
 
Hi,
reference your option buttons in the criteria of the query which the report
is based on.
When you run the query/report you the query should limit its results based
on the forms selection.
You can then open the report with something like this:

DoCmd.OpenReport Me!lbxSelectReport, acViewPreview

Where lbxSelectReport would be the combobox which holds the report names.
Is that what you want?
HTH
Good luck
 
There are several ways you can achieve this.

1st - You could use Access macros to open the report you want.
2nd - You can use VBA to run this instead.

Personally I'd always opt for the 2nd option as I hate Access macros.

Things you need to think about.....

1. Your combo boxes and option buttons. I'm assuming from what you have
written that you want these to actually affect how a query is run for the
data to be gathered. You will need to define these in your queries.

2. In VBA to get a button to run open a report use this...

Sub SomeCommandButtonYouCreated_Click()

Docmd.OpenReport (More info is needed here, but the help text will help here)

End Sub

Hope this helps you on your way.

Dave.
 
Thank you,

You have given me some options.

DaveO said:
There are several ways you can achieve this.

1st - You could use Access macros to open the report you want.
2nd - You can use VBA to run this instead.

Personally I'd always opt for the 2nd option as I hate Access macros.

Things you need to think about.....

1. Your combo boxes and option buttons. I'm assuming from what you have
written that you want these to actually affect how a query is run for the
data to be gathered. You will need to define these in your queries.

2. In VBA to get a button to run open a report use this...

Sub SomeCommandButtonYouCreated_Click()

Docmd.OpenReport (More info is needed here, but the help text will help here)

End Sub

Hope this helps you on your way.

Dave.
 
Back
Top