Requery a subform on another form

G

Guest

I have a form [FC4_PplOrg] that displays various info about a person's
relationship with an organization. One subform [FC4s1_KeyPeopleList] shows
the person's roles.

A button next to the subform opens another form [FC4Z_EditOrgRole] in which
the user can edit aspects of those roles. This form shows the person's and
org's name, and has a continuous subform [FC4Zs_subOrgRoles] that shows the 1
or more roles for that person.

A user can edit or add roles in the subform. Then the mainform
FC4Z_EditOrgRole has a "Save" button with this code in the "btnSave_Click()"
event:

Private Sub btnSave_Click()

Dim frm As Form
Set frm = Screen.ActiveForm

' Requery source of data for "Master Form".
Forms!FC4_PplOrg.FC4s1_KeyPeopleList.Requery

DoCmd.Close

End Sub

(I assume I don't need to "commit" the changes in the subform to the
underlying tables because by moving focus back to the main form the data is
automatically saved.)

When I click Save - I get Run-time error '2465', Application-defined or
object-defined error".

I assume I'm not refering to the subform on the other form correctly.

If so - what should I do. I not - ditto.

Thanks in advance - John D
 
G

Guest

Try this:

Forms!FC4_PplOrg.FC4s1_KeyPeopleList.Form.Requery

The code you have used is trying to requery a subform control on FC4_PplOrg,
this does not have a Requery method.

What you have on your main form is a subform control. This is not the
subform itself but a container for it. You can in fact change the properties
of this control to display another subform and this is often used when there
is a requirement for displaying multiple subforms in the same location rather
than having stacked subforms because ovelapping controls in your forms can
cause problems.

Most likely, your subform control has the same name as your subform (but it
doesn't have to) so you need to use the .Form property to reference the form
that it currently contains. So it is actually like this:

Forms!YourForm.YourSubformControl.Form

Steve
 
G

Guest

SteveM said:
Try this:

Forms!FC4_PplOrg.FC4s1_KeyPeopleList.Form.Requery

Good grief, Steve. I swear I copied my code and pasted it into my original
post - but the "Form" was left out somehow. : \

I have exactly the code you've suggested:

Forms!FC4_PplOrg.FC4s1_KeyPeopleList.Form.Requery

Don't really know what happened. (I have to suspect "user error" however.)

So - thanks - but that's the code I've got - and I'm still getting the error.

John D
 
G

Guest

Are you sure that FC4s1_KeyPeopleList is the name of your subform control?
It may be the name of your subform but not necessarily the subform control
that contains it...you need to use the name of the subform control.

Have you set a break point to see if that is actually the line where the
error is occurring?

Also, you don't need the lines that declare and set a Form object unless you
have moe code there that you have not shown.

Steve

Steve
 

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