requery a subform?

kwtmd

Registered User.
Local time
Yesterday, 19:03
Joined
May 21, 2004
Messages
46
I am updating records in a file by adding using recordset VBA code. These are displayed in a subform. I have tried all different combinations of requery without much success.... I know I just don't grasp the concept. Help.

I am using Forms!myformname.requery

It usually comes with an error that cannot find that form..... If I extract so to speak, the subform and use it as an separate form, the code works fine.
 
You seem to be requery the form (which you don't have open) instead of the subform.

Try
Me!SubForm.requery
where SubForm is the name of the subform in your main form

-Jake
 
1. you should not be running queries in the background that are updating records that are in your form's recordset. This is poor practice and can lead to locking conflicts.
2. The proper way to refer to the curren form from within its own class module is with .Me. So to requery the current form, use:
Me.Requery
To requery a subform from within the main form:
Me.SubformControl.Requery
To requery the parent form from within a subform:
Me.Parent.Requery
 
I am still not getting this....

I have tried VBA code as suggested (I think) but still get errors that form cannot be found or object issues.... At what event should I be using the requery? At the on current?

As for the background issue, I am using an outside table and check boxes to select various records that are then saved into the form that the subform shows. If I close the form and reopen the form, the subform reveals the correct added records. I was hoping a requery would save me the trouble.
 
At what event should I be using the requery?
- you should do the requery immediately after you update the subform's recordsource. So, if you're running an update query, requery the subform after that.
 
still unsuccessful. Error state it cannot find the form. The form/subform is open. What am I doing wrong?
 
Are you sure you typed the form name correctly in the code?
 
yes....

subform name is frmPatGoalProb


code:
forms!frmPatGoalProb.requery

produces --> Access can't find the form.....

the main form with subform are open. I have tried placing code in main form, subform and tried various combinations of the Me!frmPatGoalProb.requery.... without success.....
 
Try this:
Forms![main form name]![subformname].Requery
 
tried it but it still states it cannot find the subform?
 
I already posted the syntax for referring to a subform from its parent form. Why not try that?

If you insist on using the external syntax, you must include the complete path to the object:

forms!YourMainForm.Form!frmPatGoalProb.requery
 
You need the name of the subform as it appears on the main form property sheet and not in the db window.
Use the code builder to get the syntax correct
 
Thanks.... the answer was using the name of the form that the main form referenced. I had changed the name of the frmPatGoalProb to "Goal"... it now works. Why I changed the name I'll never know. Thanks to all of you for your perserverance....
 

Users who are viewing this thread

Back
Top Bottom