Hi,
I have a problem. My Main Form is a Popup Window with print button for other subforms. So I have it set so when the Report opens it hides the Main Form, and I use the
do get focus to Report, and I run a loop just to make sure it does actually have focus and the Main Form does not have focus.
On my PC It works great it prints the report every single time, but when my colleagues are using it... it prints the Main Form instead of the report. I don't get why it would work on my PC, but not work on someone elses?
I don't quite get it..
How can I make sure it prints the report and not the MainMenu
I have a problem. My Main Form is a Popup Window with print button for other subforms. So I have it set so when the Report opens it hides the Main Form, and I use the
Code:
DoCmd.SelectObject acReport, Reports(0).Name, True
On my PC It works great it prints the report every single time, but when my colleagues are using it... it prints the Main Form instead of the report. I don't get why it would work on my PC, but not work on someone elses?
I don't quite get it..
Code:
Public Sub FocusOnReport()
Dim intState As Integer
Dim intCurrentType As Integer
Dim strCurrentName As String
intCurrentType = Application.CurrentObjectType
strCurrentName = Application.CurrentObjectName
DoCmd.SelectObject acReport, Reports(0).Name, True
Debug.Print "Before Loop " & strCurrentName & " - " & intCurrentType
Dim cntLoop As Integer: cntLoop = 0
Do Until intCurrentType = acReport
DoCmd.SelectObject acReport, Reports(0).Name, True
intCurrentType = Application.CurrentObjectType
strCurrentName = Application.CurrentObjectName
cntLoop = cntLoop + 1
If cntLoop > 10 Then
Exit Do
End If
Debug.Print "Looped " & cntLoop & " times = " & strCurrentName & " - " & intCurrentType
Loop
End Sub
Public Function rptMinimize(Optional FormName As Variant) ' used in report load event. Minimizes MainMenu
On Error GoTo Exit_Sub
If (Screen.Application.Reports.Count > 0) Then
CloseHiddenTimerForms
Forms!MainMenu.Visible = False
FocusOnReport
If Not IsMissing(FormName) Then
Dim Frm As Form: Set Frm = Forms(FormName)
Frm.Visible = False
End If
FocusOnReport
DoCmd.Maximize
Debug.Print Application.CurrentObjectType
End If
Exit Function
Retry_Sub:
CloseHiddenTimerForms
Forms!MainMenu.Visible = False
FocusOnReport
DoCmd.Maximize
Exit Function
Exit_Sub:
If Not err.Number = 2457 Then
GoTo Retry_Sub
End If
Debug.Print ("Report Minimize: " & err.Number & err.Description)
Debug.Print Application.CurrentObjectType
Exit Function
End Function
How can I make sure it prints the report and not the MainMenu