How to see the update in a subform (requery)

G

Guest

Hello,

In my application I have a form called "frmContacts". Record Source
[tblContacts], with Primary Key [ContactID].
In this form I have a subform "frmContactFunctions". Record Source
[tblContactFunctions], with Primary Key [ContactFunctionsID] and Foreign Key
[ContactID].
The two forms are linked with Link Child Fields [ContactID] and Link Master
Fields [ContactID].

Starting from the form "frmContacts" (without closing it) I can start an
other form called "frmContactsEdit" to edit a contact and its functions.
When via form "frmContactsEdit" any change has been saved to
tblContactFunctions (new functions linked to a contact or functions deleted
from a contact) I need to requery the subform "frmContactFunctions", so I can
see the changes there.

I use this code to do that:
Forms("frmContacts").frmContactFunctions.Form.Requery
in the form "frmContactsEdit"
But I get an error.

Forms("frmContacts").frmContactFunctions.Requery
I also get an error.

Not sure if
Forms("frmContacts").Requery or Forms("frmContacts").Form.Requery will do
the job? And what is the difference between these two?

Thanks for you help
 
M

Marshall Barton

RW said:
In my application I have a form called "frmContacts". Record Source
[tblContacts], with Primary Key [ContactID].
In this form I have a subform "frmContactFunctions". Record Source
[tblContactFunctions], with Primary Key [ContactFunctionsID] and Foreign Key
[ContactID].
The two forms are linked with Link Child Fields [ContactID] and Link Master
Fields [ContactID].

Starting from the form "frmContacts" (without closing it) I can start an
other form called "frmContactsEdit" to edit a contact and its functions.
When via form "frmContactsEdit" any change has been saved to
tblContactFunctions (new functions linked to a contact or functions deleted
from a contact) I need to requery the subform "frmContactFunctions", so I can
see the changes there.

I use this code to do that:
Forms("frmContacts").frmContactFunctions.Form.Requery
in the form "frmContactsEdit"
But I get an error.

Forms("frmContacts").frmContactFunctions.Requery
I also get an error.

Not sure if
Forms("frmContacts").Requery or Forms("frmContacts").Form.Requery will do
the job? And what is the difference between these two?


Forms("frmContacts").frmContactFunctions.Form.Requery

is correct syntax. Prior to A2002 or 2003 the abbreviated
syntax usually worked, even though it was ambiguous as to
whether you were refering to the subform control or the form
object it was displaying.

The critical part of this kind of reference is to make sure
you are using the name of the subform **control**, which
might be different from the name of the displayed form
object.
 
G

Guest

Thanks Marshall,

Until now I always used this syntaxt and I always worked.
The name of the subform is the the name of the displayed form object.

Anyway I found this syntax on the web and it work:

Forms!frmContacts!frmContactFunctions.Requery

Best regards,
--
RW


Marshall Barton said:
RW said:
In my application I have a form called "frmContacts". Record Source
[tblContacts], with Primary Key [ContactID].
In this form I have a subform "frmContactFunctions". Record Source
[tblContactFunctions], with Primary Key [ContactFunctionsID] and Foreign Key
[ContactID].
The two forms are linked with Link Child Fields [ContactID] and Link Master
Fields [ContactID].

Starting from the form "frmContacts" (without closing it) I can start an
other form called "frmContactsEdit" to edit a contact and its functions.
When via form "frmContactsEdit" any change has been saved to
tblContactFunctions (new functions linked to a contact or functions deleted
from a contact) I need to requery the subform "frmContactFunctions", so I can
see the changes there.

I use this code to do that:
Forms("frmContacts").frmContactFunctions.Form.Requery
in the form "frmContactsEdit"
But I get an error.

Forms("frmContacts").frmContactFunctions.Requery
I also get an error.

Not sure if
Forms("frmContacts").Requery or Forms("frmContacts").Form.Requery will do
the job? And what is the difference between these two?


Forms("frmContacts").frmContactFunctions.Form.Requery

is correct syntax. Prior to A2002 or 2003 the abbreviated
syntax usually worked, even though it was ambiguous as to
whether you were refering to the subform control or the form
object it was displaying.

The critical part of this kind of reference is to make sure
you are using the name of the subform **control**, which
might be different from the name of the displayed form
object.
 
M

Marshall Barton

RW said:
Thanks Marshall,

Until now I always used this syntaxt and I always worked.
The name of the subform is the the name of the displayed form object.

Anyway I found this syntax on the web and it work:

Forms!frmContacts!frmContactFunctions.Requery


As I said before, older versions of Access (incorrectly)
allowed you to omit the .Form property, but newer versions
require it.

To be safe in the future, use
Forms!frmContacts!frmContactFunctions.FORM.Requery
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top