John Colby
jcolby at colbyconsulting.com
Tue Jul 1 12:45:34 CDT 2003
MessageRoz, I designed a message class for just this kind of thing. The class accepts messages in a method, then raises a message event. I instantiate the class globally (shhhhhh) such that anyone can sink the classes events. Form1 dims an instance of the class, but instead of doing: set MyMsgInstance = new... it simply gets a copy of the global class instance: Set MyMsgInstance = gclsMsg (the global instance) Form1 opens the pop up form (or any other form really). It can either send it's name in the OpenArgs as it opens Form2 or... Form2 can instantiate an instance of the message class as well. It then listens for messages. Form1 sends a message to form2 passing it's name in From: and form2's name in the To: Either way, Form2 knows who opened it now. When it is done with it's task, it sends a message back To: form1 From: Form2. Form1 gets the message and handles the data. I wrote the message class up as an article and the article is out on the dba site, along with a demo of using it. John W. Colby www.colbyconsulting.com -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Roz Clarke Sent: Tuesday, July 01, 2003 1:30 PM To: 'Access Developers discussion and problem solving' Subject: RE: [AccessD] Calling control (WAS How do I determine which form called?) You know, I think it does J The control name + parent form information should be enough to identify the calling control to the extent that each form can check to see whether it needs to respond to the event or not - by passing the control and parent information up to frmTextZoom and back again, I can pinpoint the calling control and grab the data. (Necessary because all open forms (barring menus) will have to contain the sink event and all will be responding in exactly the same way). It rests on the assumption that I only use each subform control name once throughout the database - if I instantiate a form twice, or if I've re-used a subform, I am stuffed because both copies of the form will think they own the calling control. A lot closer though. Roz -----Original Message----- From: Charlotte Foust [mailto:cfoust at infostatsystems.com] Sent: 01 July 2003 18:12 To: Access Developers discussion and problem solving Subject: RE: [AccessD] Calling control (WAS How do I determine which form called?) If you're using 2002, you can declare a custom event in the unbound form's (I assume that's frmTextZoom) module: Public Event Something(ReturnValue As String) Then somewhere in frmTextZoom, you raise the event Something and pass the value you want to capture as the return value. Any form with an active sink for that event will sink it and use the return value however it's been programmed to. In the original form, you can declare an object variable like this in the module's declarations: Dim WithEvents mfrmZoom As Form_frmTextZoom And you create a sink for the zoom form's custom event like this: Private Sub mfrmZoom_Something(ReturnValue As String) 'do something here End Sub Does that help? Charlotte Foust -----Original Message----- From: Roz Clarke [mailto:roz.clarke at donnslaw.co.uk] Sent: Tuesday, July 01, 2003 8:16 AM To: 'Access Developers discussion and problem solving' Subject: RE: [AccessD] Calling control (WAS How do I determine which form called?) From the unbound form? As in, a frmTextZoom has been launched kind of event? And then write that event into every control that has the ability to launch frmTextZoom so that when frmTextZoom closes it can jump up and go, 'that's my text, that is'??? Wouldn't I need to raise the event from the calling control before the focus gets passed to the unbound form? Otherwise, once the focus has been passed I don't have any way of referencing the control/form combination that called frmTextZoom, which is the whole problem. I think the answer is in there somewhere, thank you J Roz -----Original Message----- From: Charlotte Foust [mailto:cfoust at infostatsystems.com] Sent: 01 July 2003 16:01 To: Access Developers discussion and problem solving Subject: RE: [AccessD] Calling control (WAS How do I determine which form called?) Have you tried raising a custom event from the unbound form and sinking the event on the form that needs to retrieve the information? Charlotte Foust -----Original Message----- From: Roz Clarke [mailto:roz.clarke at donnslaw.co.uk] Sent: Tuesday, July 01, 2003 12:18 AM To: 'Access Developers discussion and problem solving' Subject: [AccessD] Calling control (WAS How do I determine which form called?) This is interesting. I need to do something sort of similar... I have an unbound text box on an unbound form which I want to use to display memo fields that are too small to display all their data in the controls on my main forms. To get the data out is easy - screen.activecontrol will do it. But then if they amend the data I need to get the new string back into the right control on the right form. Trouble is it could be up to 3 layers deep on subforms and as far as I can tell, to get the data back in I need to build a full reference to the calling control e.g. Forms!frmLevel1!frmLevel2.form!frmLevel3.form!ctrlCalling Does anyone have an idea of how I could do this when I don't know how many forms are involved??? TIA Roz -----Original Message----- From: Charlotte Foust [mailto:cfoust at infostatsystems.com] Sent: 30 June 2003 18:13 To: Access Developers discussion and problem solving Subject: RE: [AccessD] How do I determine which form called? I make CalledFrom a property of my forms. Then I can pass the calling form's name in the OpenArgs string and let the called form populate its own property. When I close the called form, it checks its CalledFrom property and goes back to that. In 2002 you can do this with Reports as well. Charlotte Foust -----Original Message----- From: Hale, Jim [mailto:jim.hale at fleetpride.com] Sent: Monday, June 30, 2003 6:04 AM To: 'Access DatabaseAdvisors (E-Mail)' Subject: [AccessD] How do I determine which form called? Does anyone have a function that will allow a class to determine which form called it? TIA Jim Hale -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030701/602a4560/attachment-0001.html>