requery form (1 Viewer)

benjamin.weizmann

Registered User.
Local time
Today, 05:06
Joined
Aug 30, 2016
Messages
78
hi :)
I'll do my best explain all my stages:

1. I made a query

2. I made a form (from1) based on this query
when clicking on record, form2 opens.

3. I made from this form1 a same sub-form (subform1) for 2 different forms (from3, from4)

4. when exit from from2 I want to requery:
subfrom1 of from3 if I arrived to form2 by form3 or
subform1 of form4 if I arrived to from2 by form4

how can I do it please?

thanks u so much

Ben
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:06
Joined
May 7, 2009
Messages
19,169
i cannot follow, but the syntax
that you will be using on the Close Event
of the form that is Exiting is:

[Forms]![MainFormName]![SubFormNameToRequery].Form.Requery

eg:

Private Sub Form_Close(Cancel As Integer)
[Forms]![MainFormName]![SubFormNameToRequery].Form.Requery
End Sub
 

benjamin.weizmann

Registered User.
Local time
Today, 05:06
Joined
Aug 30, 2016
Messages
78
i cannot follow, but the syntax
that you will be using on the Close Event
of the form that is Exiting is:

[Forms]![MainFormName]![SubFormNameToRequery].Form.Requery

eg:

Private Sub Form_Close(Cancel As Integer)
[Forms]![MainFormName]![SubFormNameToRequery].Form.Requery
End Sub

thanks you
I know it but... on close event ..how I can requery the parent (source-form) generally (without knowing the specific parent) or how can I following which was the parent -form ?

thanks
Ben
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:06
Joined
May 7, 2009
Messages
19,169
on opening the Child form, passed the name
of the Parent form as a parameter (OpenArgs):

eg, say you are opening "Form2" from "FormMain":

DoCmd.OpenForm Formname:="Form2",View:=acNormal,OpenArgs:=Me.Name

Me.Name (the name of the parent invoking form) is passed to
the invoked form. then in the invoked form (Form2) catches
this value and can be used on its Close Event:

Private Sub Form_Close()

If Trim(Me.OpenArgs & "") <> "" Then
' add code to test which Parent
' this belongs and Requery its appropriate
' subform
IF Me.OpenArgs = "Form1" Then
Form(Me.OpenArgs)("subFormOfNameForm1").Form.Requery
End If

' check for other Forms
IF Me.OpenArgs = "Form3" Then
Form(Me.OpenArgs)("subFormOfNameOfForm3").Form.Requery
End If

End Sub
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 12:06
Joined
Jul 9, 2003
Messages
16,244
I'm not entirely clear about your question either.. But; in view of your statement here:-

..how I can requery the parent (source-form) generally (without knowing the specific parent) or how can I following which was the parent -form ?
Ben

I'm guessing you need to find the main form that a subform is housed within...

I think you are running into a problem I addressed in my set of videos on building a class module - 10) - Class Module - Broken! - Nifty Access

The problem in Coding for this is, you would naturally look at each object and ask are you an object or are you a form? However, the problem I ran into was, as I stepped up through the levels of parent after parent, when you got to the level of the form, passing the form in to the object variable caused an error. This error was caused because the form was the wrong type of object for the object variable. The solution was not to look at the object as an object, but extract the objects name. Now you can examine the Forms collection for the name as text and you don't get an error. There might be some errors and omissions in my description!
 

Users who are viewing this thread

Top Bottom