Results 1 to 2 of 2
  1. #1
    Join Date
    May 2016
    Posts
    80
    Provided Answers: 3

    Answered: Multiple Report Instances :how to Set Focus on particular opened instance

    Hi


    My problem is to set the focus on a particular Report instance opened . I copy a function which works perfectly for form object but not for Report object. My function:


    Code:
    Function mInstanceReportCA(varYear As Variant)
           
        Dim oReport As Access.Report
        Dim obj As Object
        
        ' Création du nouveau formulaire
        For Each obj In clsReport
            If obj.txtYear = varYear Then
                obj.Visible = true
                obj.SetFocus '---------------------------> Error 2465
                Exit Function
            End If
        Next obj
        
        Set oReport = New Report_rptCaMois
        
        ' Activation du nouveau formulaire
        With oReport
            
            If varYear = "1999" Then
                .txtYear = "1999"
                .Caption = "Rapport toutes années confondues"
                .Filter = "Year(dateFacture) > 1999 "
            Else
                .txtYear = CStr(varYear)
                .Caption = "Rapport pour l'année  " & CStr(varYear)
                .Filter = "Year(dateFacture) = " & varYear
            End If
            .FilterOn = True
            .Visible = True
        End With
        
        
        ' Ajout du formulaire à la collection globale
        clsReport.Add Item:=oReport, Key:=CStr(oReport.Hwnd)
       
        Set oReport = Nothing
        
    End Function



    In the loop routine, These commands below generate error message
    Code:
       For Each obj In clsReport
            If obj.txtYear = varYear Then
                obj.Visible = true
                obj.SetFocus '---------------------------> Error 2465
                Exit Function
            End If
        Next obj

    Any idea how to to move into the foreground a particular instance?

    thanks for your help :banghead:
    Last edited by informer; 06-03-16 at 10:11.

  2. Best Answer
    Posted by informer

    "We need to use BringWindowToTop API windows

    Declaration on general part module Public Declare Function BringWindowToTop Lib "user32" (ByVal hWnd As Long) As Long

    In the code -> BringWindowToTop obj.hwnd

    Thanks to Dirk Goldgar"


  3. #2
    Join Date
    May 2016
    Posts
    80
    Provided Answers: 3
    We need to use BringWindowToTop API windows

    Declaration on general part module Public Declare Function BringWindowToTop Lib "user32" (ByVal hWnd As Long) As Long

    In the code -> BringWindowToTop obj.hwnd

    Thanks to Dirk Goldgar

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •