LenaWood
asked on
Set Focus using Global Variable
This is an extension of this question:
https://www.experts-exchange.com/questions/21981827/Log-a-Report-as-being-printed.html
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!
Lena
https://www.experts-exchange.com/questions/21981827/Log-a-Report-as-being-printed.html
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!
Lena
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
Lena
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.
Lena
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("tblRepor tLog")
rs.AddNew
rs!PrintDate = Now()
rs!DoneBy = Forms!frmUserInfo!UserName
rs!ReportName = Application.Screen.ActiveR eport.Name
rs.Update
rs.Close
Set rs = Nothing
End Sub
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("tblRepor
rs.AddNew
rs!PrintDate = Now()
rs!DoneBy = Forms!frmUserInfo!UserName
rs!ReportName = Application.Screen.ActiveR
rs.Update
rs.Close
Set rs = Nothing
End Sub
ASKER
Any other way to check if it is open? The only way it can be opened is in preview.
Lena