print current report inside of navigation form access 2010

Hi guys,

I'm creating this navigation form in Access 2010 which will let me pick a report listed on the right side of the navigation form and show it in the left side. Well, I'm trying to add a button to be able to print any report picked. I can't find a way to do this!!! Everything I have tried lets me just print one report in specific because when I create the button I have to enter the name of the report that I want to open or print and I don't want to do that!! I want to be able to pick any report from the right side of my navigation form and then click the button and open or print the report! I kind know that I need to use either a Macro or Code but I'm not sure how to write the code or Macro to do what I want it to do....


Could you give me a hand or guide in the right direction?


Thanks,
hugonietoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jeffrey CoachmanMIS LiasonCommented:
On the Gotfocus event of Each Report put code like this:

Private Sub Report_GotFocus()
    If CurrentProject.AllForms("YourNavigationFormName").IsLoaded = True Then
       DoCmd.OpenReport Me.Name
    End If
End Sub


JeffCoachman
0
Jeffrey CoachmanMIS LiasonCommented:
Oh, I think I see now..

...a bit more work:

1. Create a public variable in a module:
    Public strpubReportName As String

2. Put code like this on Each Report's GotFocus event:
    strpubReportName = Me.Name

3. Put this code on your Nav form button's "Click" event (I put my button in the Nav Form Header)
    DoCmd.OpenReport strpubReportName
    strprvtReportName = ""
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hugonietoAuthor Commented:
Thanks boag2000..... What do you mean in the 1st step? I mean where or how can I create a public variable in a module? I'm sorry for my lack of experience in this...


Thanks,
0
Redefine Your Security with AI & Machine Learning

The implications of AI and machine learning in cyber security are massive and constantly growing, creating both efficiencies and new challenges across the board. Check out our on-demand webinar to learn more about how AI can help your organization!

Jeffrey CoachmanMIS LiasonCommented:
sorry...

Open your database
Press Alt+F11, to open the visual basic editor
Click: Insert-->Module
0
hugonietoAuthor Commented:
Great! Let me try it! Thanks
0
hugonietoAuthor Commented:
Boag2000!! It worked perfect!! THANKS a lot!! just one think.... in some printers it prints double sided even though the printer is not set to print double sided... do you have any idea why? But in another printers prints perfect in one side....


Thanks a lot man!!
0
Jeffrey CoachmanMIS LiasonCommented:
...That sounds like a Printer or printer driver issue, ...not sure
0
hugonietoAuthor Commented:
Thanks a lot for all the help!! Thanks man!
0
Jeffrey CoachmanMIS LiasonCommented:
;-)
0
Jeffrey CoachmanMIS LiasonCommented:
Actually this was an interesting and thought provoking question, so I must thank you as well...
;-)
0
Roque mansiliohanCommented:
I've been browsing the web for a while for answers on this question and finally landed on this page. Your solution is especially helpful that I have to login just to thank you!

Many Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.