Requery (1 Viewer)

kirkm

Registered User.
Local time
Today, 23:51
Joined
Oct 30, 2008
Messages
1,257
I would like to requery my Form but can't work out the Syntax. There's a Form on a Form which may or may not be a Subform. I expected it to be a subform, but don't think it ended up one.
Its name is FormRunSub, and the Form its on is FormRun.

FormRunSubs Recordsource is qryCRun. and the button to requery it is
on Form Run. What doesn't work is

Code:
Dim stl as Control
Set stl = Forms!Form_FormRunSub.RecordSource.Requery
Thanks for any correction.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 07:51
Joined
May 21, 2018
Messages
8,555
Code:
me.formRunSub.form.requery
That assumes the subform control has the same name as the subform, "formRunSub"
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:51
Joined
Oct 29, 2018
Messages
21,498
Hi. I would also recommend a relative reference, like what MajP showed, rather than an absolute one, if possible. Cheers!
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 21:51
Joined
Jan 20, 2009
Messages
12,853
Code:
Dim stl as Control
Set stl = Forms!Form_FormRunSub.RecordSource.Requery

You wouldn't set a variable like this. You simply want to run the Method.

Also note that Form_FormRunSub is a reference via the form's module and it should never be referred to using this name.

Using this name will open a hidden instance of the form if it isn't already open. This hidden instance cannot be properly distinguished from any subsequent instance loaded with OpenForm.
 

kirkm

Registered User.
Local time
Today, 23:51
Joined
Oct 30, 2008
Messages
1,257
Galaxiom I got that example from a Google search... looked authentic. But that and the advice from MajP gives teh same error "Method or Data member not found"
>assumes the subform control has the same name as the subform, "formRunSub"



Not sure. I have a subform control ? It's a Form dragged onto a Form and displayed in Datasheet View, so it can include a couple of Buttons. One is to requery it after an edit.



I've been trying to confirm the form names... I click in the square where the vertical and horizontal rulers meet and it Opens a property but doesn't show the Form Name anywhere. How can that be??? The name is always there, isn't it?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:51
Joined
Oct 29, 2018
Messages
21,498
Galaxiom I got that example from a Google search... looked authentic. But that and the advice from MajP gives teh same error "Method or Data member not found"
>assumes the subform control has the same name as the subform, "formRunSub"

Not sure. I have a subform control ? It's a Form dragged onto a Form and displayed in Datasheet View, so it can include a couple of Buttons. One is to requery it after an edit.

I've been trying to confirm the form names... I click in the square where the vertical and horizontal rulers meet and it Opens a property but doesn't show the Form Name anywhere. How can that be??? The name is always there, isn't it?
Hi. See if this old article helps...
 

kirkm

Registered User.
Local time
Today, 23:51
Joined
Oct 30, 2008
Messages
1,257
A quickish look seems he's suggesting the format MajP said. That isn't working here



KEY CONCEPT: When referring to subforms on a main form you will refer to the CONTROL NAME (screenshot says “CONTAINER” but it is the subform control)and not the subform name.


I can't see where/what the control name or subform name to try what's he saying. I have FormnRun in design mode. Whereabouts is the subForm or Control name?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:51
Joined
Oct 29, 2018
Messages
21,498
A quickish look seems he's suggesting the format MajP said. That isn't working here

KEY CONCEPT: When referring to subforms on a main form you will refer to the CONTROL NAME (screenshot says “CONTAINER” but it is the subform control)and not the subform name.

I can't see where/what the control name or subform name to try what's he saying. I have FormnRun in design mode. Whereabouts is the subForm or Control name?
Well, I was hoping the screenshots/images on the article would help you figure that part out because it's really hard to explain, but I'll try anyway. If you go to the Design View of your form, click once (only once) into the subform area. Then, go to the Properties Window and make sure the "Selection type:" says Subform/Subreport; and if so, check out what is in the Name property. This is the one you're supposed to use in the syntax.
 

kirkm

Registered User.
Local time
Today, 23:51
Joined
Oct 30, 2008
Messages
1,257
If I got to the code window in FormRun and type "Me" the drop down list does NOT include "FormRunSub".



Should it not be there?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 07:51
Joined
May 21, 2018
Messages
8,555
I can't see where/what the control name or subform name to try what's he saying. I have FormnRun in design mode. Whereabouts is the subForm or Control name?

Basically is is a container (subform control) with an object inside it (form or datasheet). If you click on the outside edge you will get the subform control. If you click too much inside you will get the source object. By default the subform control usually gets the same name as the source object, depending on how you build it. If not it will get a name like Child1. To see the real name of the subform control you need to select the subform control and not the source object.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 07:51
Joined
May 21, 2018
Messages
8,555
Should it not be there?
How about "Child1" or some other Child...?
 

kirkm

Registered User.
Local time
Today, 23:51
Joined
Oct 30, 2008
Messages
1,257
If I click once in the SubForm area, the Property Sheet Seelction shoes "Detail"
If I click where the rulers meet it says "Form". I see that for both FormRun and FormRunSub.


No Name property can be found. Bugger....
 

kirkm

Registered User.
Local time
Today, 23:51
Joined
Oct 30, 2008
Messages
1,257
> How about "Child1" or some other Child...?

The only "Ch" is ChartSpace
 

Micron

AWF VIP
Local time
Today, 07:51
Joined
Oct 20, 2018
Messages
3,478
maybe these will help
Contrary to what was stated, if you click once on a sub form, it will activate the control/container, not the form itself. At least that's 2016 behaviour.
 

Attachments

  • Sfrm1.jpg
    Sfrm1.jpg
    39.5 KB · Views: 43
  • Sfrm2.jpg
    Sfrm2.jpg
    38.3 KB · Views: 39

kirkm

Registered User.
Local time
Today, 23:51
Joined
Oct 30, 2008
Messages
1,257
I never see
Selectionm type: Subform/Subreport
as in Sfrm1.jpg. Only "Form"


The label (?) that says Child0 has gone now... I deleted it although it didn;'t say "Child0".
 

Micron

AWF VIP
Local time
Today, 07:51
Joined
Oct 20, 2018
Messages
3,478
had to try your method of dragging form onto a form in design view. The resulting objects behave the same but container selection type still says subform/subreport as in image 1. Label says Form10 and control list (combo) says Form10. Whatever your label said is probably what your container name is. As long as you can activate the container (subform control) as in pic 1, you should be able to know its name as in pic 1.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 07:51
Joined
May 21, 2018
Messages
8,555
This will give you the name if all else fails.
Code:
Private Sub Form_Load()
  Dim ctl As Access.Control
  For Each ctl In Me.Controls
    If ctl.ControlType = acSubform Then
      MsgBox ctl.Name
    End If
  Next ctl
End Sub
 

kirkm

Registered User.
Local time
Today, 23:51
Joined
Oct 30, 2008
Messages
1,257
Looks like everyone's given up, I'll keep at it and figure out some way of doing it.

Thanks for trying.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:51
Joined
Oct 29, 2018
Messages
21,498
Looks like everyone's given up, I'll keep at it and figure out some way of doing it.

Thanks for trying.
Hi. I wonder what made you say that. Everyone are still trying to give you ideas, aren't they? You know this could be resolved very easily if you could share a copy of your database with dummy data.
 

kirkm

Registered User.
Local time
Today, 23:51
Joined
Oct 30, 2008
Messages
1,257
Righteoo.. sorry. Will get a mockup done and do just that, thanks
 

Users who are viewing this thread

Top Bottom