Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Requery Secondary Form's Subform

Status
Not open for further replies.

LarryDeLaruelle

Technical User
May 19, 2000
1,055
US
I'm trying to requery a subform on a secondary/display form when a combo box on the primary form is updated.

cboselect After Update (primary form)

Forms!frmMedAuthMain.cboSelect = Me.cboSelect

This works fine to sync the primary and secondary forms to the same client.

I have tried the following to requery the secondary's subform:

Forms!frmMedAuthMain.Forms!frmMedAuthSub.Requery
Forms!frmMedAuthMain!Forms!frmMedAuthSub.Requery
These two error

Forms!frmMedAuthMain.frmMedAuthSub.Requery
Forms!frmMedAuthMain!frmMedAuthSub.Requery
No errors, but no requery either

Any help on getting this syntax correct would be greatly appreciated.

Thanks.

Larry De Laruelle
ldelaruelle@familychildrenscenter.org

 
Hi

You have the syntax a little jumbled, and it is Form not Forms, Forms is a collection of open forms, while Form is a property of a subform control

try

Forms!frmMedAuthMain!frmMedAuthSub.Form.Requery

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Thanks Ken:

Thanks for the reply; however, this does not do the trick either. No errors but it does not requery the subform.

Any other suggestions?

(You're right, I do tend to jumble the syntax on this stuff.)

Larry De Laruelle
ldelaruelle@familychildrenscenter.org

 
Hi!

It might be that the subform control name differs from the subform name as viewed in the database window. You'll need the subform control name.

You'll find the name in the properties of the subform container (where you also find the link parent/child properties, other tab).

For more info, check out this Microsoft link How to Refer to a Control on a Subform or Subreport.

Roy-Vidar
 
Hi

Yes, Roy is right, I usually emphasise the point it is the subform control name which is needed not the actual form name contained in the control, but I ommitted to emphasise it on this occasion

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Ken & Roy:

The form that has focus or is active if frmFeeSlipMain. I am attempting to sync/requery frmMedAuthMain in the After Update event of frmFeeSlipMain combo box.

The sync portion (setting frmMedAuthMain.cboSelect) works fine. Just can't seem to get the frmMedAuthSub to list the relevant records. frmMedAuthSub is a continuous form.

One thing I found in Help seems to indicate that the requery will not work if the main form is not the active form. Does this sound right? If so, is there another method that I could use to force the subform to display the records?

Just to note, I've tried issuing the requery from frmMedAuthMain in the On Current event and the After Update and Change events of the combo box.

Thanks for the suggestions.

Larry De Laruelle
ldelaruelle@familychildrenscenter.org

 
Try this:
From anywhere else than the main form on which this subform resides, use the expression builder (right click in a control source/criteria row of a query, whatever). Double click thru forms, loaded forms, main form, subform and a control on the subform. You should get a reference looking like this:

[tt]forms![frmMain]![subformCONTROLname].Form![controlname][/tt]

The part before the controlname should be the correct reference to the subform, use:

[tt]forms![frmMain]![subformCONTROLname].Form.Requery[/tt]

As long as the subform is referenced correctly (as also shown in the link I provided), by the control name not the subform name, this should work (at least it does so on my setup(s)). For test, use it in an on click event first, then experiement later with other events.

Roy-Vidar
 
Roy:

Using the expression builder in a query, I stepped down to the form and got this:

Forms![frmMedAuthMain]![frmMedAuthSub]

I then added this part per your instruction.

.Form.Requery

to get this:

Forms![frmMedAuthMain]![frmMedAuthSub].Form.Requery

I put a command button on the form and put this code in the On Click event. Still no joy.

Just to clarify, I'm using A2K with the DAO reference set.



Larry De Laruelle
ldelaruelle@familychildrenscenter.org

 
When I do this:

myself said:
Double click thru forms, loaded forms, main form, subform [blue]and a control on the subform[/blue]. You should get a reference looking like this:

forms![frmMain]![blue][subformCONTROLname].Form![controlname][/blue]

I get exactly the reference above. (Including the .Form![Controlname]) where the subformcontrolname is different from the subformname. Did you also doubleclick a control on the subform?

OK - another way to get the reference (as described in first post). Find the properties where you can find the link master/child properties of the subform container. When you see those, click the "other" tab. The name found there is the subform controlname, which is needed in this reference.

That said, there could also be some timing issues. Try stepping thru the code line by line, and see if that makes any difference (set the combo value first, then execute the requery).

Roy-Vidar
 
Roy:

Yes, I stepped down to a control on the subform like so:

Forms![frmMedAuthMain]![frmMedAuthSub].Form![SvcTypeDesc]

Then replaced the ![SvcTypeDesc] with .Requery.

I have tried stepping through the code both with the requery on the calling form (frmFeeSlipMain) and on the secondary form (frmMedAuthMain). In either case, I can step through the code with no errors but with no results either.

One thing I have noticed, is that when I run the code I can see the cursor flicker in the subform even though nothing else happens.

Thanks again.

Larry De Laruelle
ldelaruelle@familychildrenscenter.org

 
What happens if you manually "dirty" a record there, and run the code?

What should happen when you requery, a "filtering" based on the combo, child/master...

(pardon if I sounded a bit stubborn, but the subform control name thingie is usually the issue in such cases;-))

Roy-Vidar
 
Roy:

Kept mumbling and fumbling and came up with this:

From frmFeeSlipMain.cboSelect After Update
Forms!frmMedAuthMain.cboSelect = Me.cboSelect
Forms!frmMedAuthMain.Requery

In the On Current event of frmMedAuthMain
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[ClientID] = " & Str(Me![cboSelect])
Me.Bookmark = rs.Bookmark
Me.frmMedAuthSub.Requery

I think the problem was that even though I was setting the value of the cbo it was not also setting the value for ClientID.

This looks a bit clunky to me, but it does work.

Thank for your help.

Larry De Laruelle
ldelaruelle@familychildrenscenter.org

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top