requering a subform on an instance of the parent form

Mr.K

Registered User.
Local time
Today, 14:35
Joined
Jan 18, 2006
Messages
104
Hi, I hope someone can help.

I have a MainForm which I had to create instances of. I found this solution on creating instances: http://allenbrowne.com/ser-35.html and used it "successfully" up to this point.

The MainForm has a subform from which I open EditRecordonSubform form. Once the record is edited I wish to requery the subform, but Forms!MainForm!sbForm.Requery doesn't work anymore because I have to refer to a particular instance of the MainForm.
(tip: after the EditRecord form closes, the focus naturally comes back to the instance of the MainForm on which the subform that needs to be requeried sits on. Is there some way to program in vba: requery the subform of the form that now has the focus? However, I don't think this would work because the MainForm doesn't receive focus until all the code is executed from the SAVE CHANGES onclick event of the EditRecord form, correct?)
 
Last edited:
I'm sure if it is unspecific enough, or clever enough :) but what about a GotFocus procedure? Don't know if that helps!
 
Thanks barno, that does help. However, if I requery the subform on gotFocus, then the subform gets requeried every time it receives focus. However I only need to re-query it after the EditRecord form closes.

Isn't re-querying the subform on each gotfocus make the DB perform worse, or maybe I shouldn't worry about it? I'm new at all this and trying to acquire good design habits, but like in this case maybe I'm over-cautious?

Thanks for all the expert advice.
 
Last edited:
form instances - lost and desperate for any help

Gotfocus doesn't do the work in the end and I'm not sure what else I can do. I'm really lost here because I don't understand the code I used for creating instances and I reached a dead end.

Here is the code that creates a new instance of my main form:
Code:
Function OpenIndividuals()
    'Purpose:    Open an independent instance of form frmClient.
    Dim frm As Form

    'Open a new instance, show it, and set a caption.
    Set frm = New Form_frmIndividuals
    frm.Visible = True
    frm.Caption = "DPDB ver1.0 ~ " & frm.LastName & ", " & frm.FirstName
    
    'Append it to our collection.
    clnClient.Add Item:=frm, Key:=CStr(frm.hwnd)

    Set frm = Nothing
End Function
from what I can understand this code adds to the collection the unique window handle (frm.hwnd) of the new instance of the form. Logically I know what i wish to do but my vba skills aren't there to support my logical solution. Here is the problem summarized differently:

Let's say my NewInstance of the MainForm opens frmSomeOtherForm. The question is: How can I upon closing frmSomeOtherForm ask to refresh a control (requery a subform to be more specific) on that NewInstance of the MainForm?

I think there should be a way to pass the window handle of that instance to the frmSomeOtherForm and then upon closing the frmSomeOtherForm use that handle to reference the correct instnace. As far as programming it, it is totally beyond my abilities.

(This would be more of an HTML:) solution and I'd rather not go this direction, but that's the only idea I have left:
What do you think about creating a hidden control on the frmSomeOtherForm that would temporary store the hwnd handle and then I would reference that handle (how?) when closing frmSomeOtherForm)
 
Last edited:

Users who are viewing this thread

Back
Top Bottom