Avatar of LenaWood
 asked on

Set Focus using Global Variable

This is an extension of this question:


The solution given worked on one machine but not another one (grrr sometimes I just LOVE my job).  Anyway, seems I am going to have to use a global variable to do this.

Do I use the global variable to set the focus on the report that is open?  If so, how?  I have already created the variable and called it strReportName.  In the on open event of the report, I have:

strReportName = Me.Name

Now how do I use this?

I guess I could use it to print the report by using DoCmd.OpenReport strReportName - but since the report is already open, would that cause an issue?

Thanks in advance for your help!
Microsoft Access

Avatar of undefined
Last Comment

8/22/2022 - Mon
Rey Obrero (Capricorn1)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

I don't think Access 2000 doesn't use CurrentView.  I found this out when I tried using it before.  When I try to compile it on a 2000 machine I get a error saying it hasn't been declared (or something similar to that).

Any other way to check if it is open?  The only way it can be opened is in preview.

Rey Obrero (Capricorn1)


Thank you for the link.

I added this line to my code:

DoCmd.OpenReport strReportName, acViewNormal

and removed all the others.  This seems to make it work just like it should.

Thanks for your help - and again, thanks for the link.

I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck

Although it appears that your problem is resolved, I thought this was worth mentioning.  It seems that that utilizing the OnPrint event of the reports' headers may be a more elegant way of creating a print log:

Private Sub ReportHeader_Print(Cancel As Integer, PrintCount As Integer)
Dim rs As DAO.Recordset
Dim db As DAO.Database
    Set db = CurrentDb
    Set rs = db.OpenRecordset("tblReportLog")  
              rs!PrintDate = Now()
              rs!DoneBy = Forms!frmUserInfo!UserName
              rs!ReportName = Application.Screen.ActiveReport.Name
    Set rs = Nothing

End Sub