Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 06-03-2016, 02:50 AM   #1
informer
Newly Registered User
 
Join Date: May 2016
Posts: 75
Thanks: 2
Thanked 15 Times in 14 Posts
informer is on a distinguished road
Send a message via Yahoo to informer
Cool 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 '---------------------------> 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

informer is offline   Reply With Quote
Old 06-03-2016, 03:00 AM   #2
Ranman256
Newly Registered User
 
Join Date: Apr 2015
Location: KY,USA
Posts: 3,367
Thanks: 0
Thanked 742 Times in 727 Posts
Ranman256 will become famous soon enough Ranman256 will become famous soon enough
Re: Multiple Report Instances :how to Set Focus on particular opened instance

Report data is controlled from the query,
There's no need for any code.
Ranman256 is offline   Reply With Quote
Old 06-03-2016, 04:21 AM   #3
informer
Newly Registered User
 
Join Date: May 2016
Posts: 75
Thanks: 2
Thanked 15 Times in 14 Posts
informer is on a distinguished road
Send a message via Yahoo to informer
Re: Multiple Report Instances :how to Set Focus on particular opened instance

Hi Ranman256,

What do you mean? It's not possible to set focus on a report instance !

In any case, for each report instance, there is an item with its Hwnd in my clsReport collection.


obj.Visible ' Error 438 corrected => obj.Visible = True/False

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


Last edited by informer; 06-03-2016 at 06:08 AM.
informer is offline   Reply With Quote
Old 06-03-2016, 02:43 PM   #4
informer
Newly Registered User
 
Join Date: May 2016
Posts: 75
Thanks: 2
Thanked 15 Times in 14 Posts
informer is on a distinguished road
Send a message via Yahoo to informer
Re: Multiple Report Instances :how to Set Focus on particular opened instance

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

informer is offline   Reply With Quote
Reply

Tags
multiple instances , report , set focus

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Solved Focus opened instance when luser tries to open a second instance Fernando General 3 09-03-2008 05:17 AM
How to open multiple instances of a report snoopy22 Reports 1 05-26-2006 11:17 PM
How to open multiple instances of a report snoopy22 Modules & VBA 2 05-25-2006 06:23 AM
Multiple instances of one report SammyJ Modules & VBA 0 01-09-2006 05:20 AM
Refering to an instance of the form with multiple instances open arvindn Forms 0 10-01-2003 11:01 PM




All times are GMT -8. The time now is 01:26 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World