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:
In the loop routine, These commands below generate error message
thanks for your help :banghead:
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 '---------------------------> Error 438
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 '---------------------------> Error 438
obj.SetFocus '---------------------------> Error 2465
Exit Function
End If
Next obj
thanks for your help :banghead: