Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 10-30-2017, 12:34 AM   #1
benjamin.weizmann
Newly Registered User
 
Join Date: Aug 2016
Posts: 78
Thanks: 53
Thanked 1 Time in 1 Post
benjamin.weizmann is on a distinguished road
requery form

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

benjamin.weizmann is offline   Reply With Quote
Old 10-30-2017, 01:55 AM   #2
arnelgp
error reading drive A:
 
arnelgp's Avatar
 
Join Date: May 2009
Location: somewhere out there
Posts: 8,581
Thanks: 68
Thanked 2,754 Times in 2,638 Posts
arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice
Re: requery form

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
__________________
"Never stop learning, because life never stops teaching"
arnelgp is offline   Reply With Quote
The Following User Says Thank You to arnelgp For This Useful Post:
benjamin.weizmann (11-20-2017)
Old 10-30-2017, 02:05 AM   #3
benjamin.weizmann
Newly Registered User
 
Join Date: Aug 2016
Posts: 78
Thanks: 53
Thanked 1 Time in 1 Post
benjamin.weizmann is on a distinguished road
Re: requery form

Quote:
Originally Posted by arnelgp View Post
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

benjamin.weizmann is offline   Reply With Quote
Old 10-30-2017, 02:27 AM   #4
Gasman
Enthusiastic Amateur
 
Gasman's Avatar
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 4,791
Thanks: 455
Thanked 905 Times in 869 Posts
Gasman is a jewel in the rough Gasman is a jewel in the rough Gasman is a jewel in the rough
Re: requery form

Me.Parent.Requery ?
__________________
Access novice. Sometimes trying to give something back.
Access 2007

Please, please use code tag # when posting code snippets

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Gasman is offline   Reply With Quote
The Following User Says Thank You to Gasman For This Useful Post:
benjamin.weizmann (11-20-2017)
Old 10-30-2017, 02:28 AM   #5
arnelgp
error reading drive A:
 
arnelgp's Avatar
 
Join Date: May 2009
Location: somewhere out there
Posts: 8,581
Thanks: 68
Thanked 2,754 Times in 2,638 Posts
arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice
Re: requery form

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.Reque ry
End If

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

End Sub
__________________
"Never stop learning, because life never stops teaching"
arnelgp is offline   Reply With Quote
The Following User Says Thank You to arnelgp For This Useful Post:
benjamin.weizmann (11-20-2017)
Old 10-30-2017, 02:29 AM   #6
Uncle Gizmo
Nifty Access Guy
 
Uncle Gizmo's Avatar
 
Join Date: Jul 2003
Location: Newbury Berks UK
Posts: 10,529
Thanks: 594
Thanked 1,007 Times in 949 Posts
Uncle Gizmo is a jewel in the rough Uncle Gizmo is a jewel in the rough Uncle Gizmo is a jewel in the rough
Send a message via Skype™ to Uncle Gizmo
Re: requery form

I'm not entirely clear about your question either.. But; in view of your statement here:-

Quote:
Originally Posted by benjamin.weizmann View Post
..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!

__________________
Code:
                 |||||
               @(~^~)@
-------------oOo---U---oOo-------------
|                                     |
|      Uncle Gizmo              |
|  
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
| | Ooo | |_________________ooO____( )________| ( ) ) / \ ( (_/ \_)
Uncle Gizmo is offline   Reply With Quote
The Following User Says Thank You to Uncle Gizmo For This Useful Post:
benjamin.weizmann (11-20-2017)
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Form won't requery rede96 Modules & VBA 32 05-22-2015 02:03 PM
requery a form by using window handle (hwnd) of that form Mr.K Modules & VBA 6 10-13-2014 05:50 PM
Requery of a form Tiger955 Forms 0 02-24-2014 07:34 AM
Requery a form Ankarn Forms 1 07-10-2008 08:21 AM
ReQuery a Different Form ddrew Forms 4 07-19-2005 05:58 PM




All times are GMT -8. The time now is 08:51 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 - 2020, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World