How Do I Print Report Based On Selected Tab

R

Rob Sorfleet

hi all. I have started using Access 2003 to create a database to keep track
of my Music CD's, DVD's and VHS films. I try and collect when ever I can and
if there is a carboot in town I like to go and check them out to add to my
collection, I currently have an Excel file with a worksheet for each item and
print out a list when ever I go to a boot sale looking for more items to add
to my collection.

In access I currently have 3 tables for each item (CD, DVD, VHS) and have a
form with a tabbed window on it, I have assigned a table to each tab so that
you only have to click on a tab to change to one of the 3 databases.

What I am having difficulties with is I want to have a single print button
on the page, which would print a report based on the tab that is currently
open. So if I ave the CD tab open and I click on the print button, it would
print the CD report same goes for the other 2 tabs.

I have had a good google and look around but cannot see/find anything that
references the use of tabs, focus and assigning reports to a button based on
the tab that has focus.

Any help would be greatly appreciated, or a pointer to a few good tab
tutorials.

thanks in advance.
Rob
 
B

BruceM via AccessMonster.com

You can use something like this to get the tab's index number (I will call
the tab control tabCol):

Me.tabCol.Value

To get the caption:
Me.tabCol.Pages(Me.tabCol.Value).Caption

You could put the report name in the Tag property of the page, then get the
value and pass it to the report call in the copmmand button's Click event:

Dim strRpt as String
strRpt = Me.tabCol.Pages(Me.tabCol.Value).Tag

DoCmd.OpenReport strRpt, acViewPreview

The acViewPreview is optional, in case you want to see the report before
printing.

You can obtain other properties such as Name in the same way as the caption
or tag. Or you could use the index number in the report call:

Dim intPage as Integer
Dim strRpt as long

Select Case intPage
Case 0
strRpt = "rptVHS"
Case 1
strRpt = "rptDVD"
Case 2
strRpt = "rptCD"
End Select

DoCmd.OpenReport strRpt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top