423,109 Members | 2,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,109 IT Pros & Developers. It's quick & easy.

Parent & Child Form Refresh/Requery Not working

Jerry Maiapu
100+
P: 259
Hi all,
I have a child and parent forms. The record source of the sub-form is query containing aggregate functions.

A combo box in the parent form filters the sub-form results based on value (name) selected.

Some values of the sub-form are accessed and displayed on the main form; A calculation is done (using values of the sub form)and final result is displayed on main form.

When clicked on a button on the main form the result is inserted into a temp table to replace an existing value. (The sub-form 's recordsource, I mentioned earlier is a query based on this temp table)

So basically after new calculated value is inserted into
the table the current calculated values on main form would change obviously when sub-form is refreshed.
Problem:
That is not happening. (Value not updated on form when requeried)

I tried

Expand|Select|Wrap|Line Numbers
  1.  
  2.         If rs!EmployeeId = Me.EmployeeId And rs!DateWorked = Me!txtdate Then
  3.          rs.Edit
  4.          rs!Reset_Value = Me.txtfinalcredit'inserting calculated value
  5.          rs.Update
  6.       End If
  7.  
  8.  
  9.  MsgBox "Credit reseted Successfully", vbOKOnly + vbInformation, "Sucessful"
  10. DoCmd.Requery "mysubform"'requery subform
  11. Me.Requery'requery all controls
  12.  
Replacing line 10 & 11 with this does not work as well:

Expand|Select|Wrap|Line Numbers
  1. Me.Refresh 
It only works (value is updated)when I select the same value using the combobox.

E.I After update event of combo box fires but nothing of above seem to work.

Hope I am contextualizing.

Someone with a better idea can help me out
Aug 16 '10 #1

✓ answered by Stewart Ross

Hi Jerry. Have you tried requerying the subform's instance that is attached to the main form rather than requerying the subform itself? The subform is a control of the main form, and I suspect that requerying the subform itself as you do at line 10 will not update the recordset instance on your main form.

The syntax in place of line 10 in your code would be something like

Expand|Select|Wrap|Line Numbers
  1. Me![Mainformname]![SubformControlName].Form.Requery
If you find that this does not work, you could try dynamically replacing the recordsource of the subform in place of the requery:

Expand|Select|Wrap|Line Numbers
  1. Me![Mainformname]![SubformControlName].Form.Recordsource = "Select * from [YourTable]"
You may well then have to requery the main form to reconnect the two, though.

The Refresh method does not cope with additions or deletions, whereas requery does; Refresh is intended for use where users may be changing existing record values in a multi-user environment.

-Stewart

Share this Question
Share on Google+
3 Replies


Expert Mod 2.5K+
P: 2,545
Hi Jerry. Have you tried requerying the subform's instance that is attached to the main form rather than requerying the subform itself? The subform is a control of the main form, and I suspect that requerying the subform itself as you do at line 10 will not update the recordset instance on your main form.

The syntax in place of line 10 in your code would be something like

Expand|Select|Wrap|Line Numbers
  1. Me![Mainformname]![SubformControlName].Form.Requery
If you find that this does not work, you could try dynamically replacing the recordsource of the subform in place of the requery:

Expand|Select|Wrap|Line Numbers
  1. Me![Mainformname]![SubformControlName].Form.Recordsource = "Select * from [YourTable]"
You may well then have to requery the main form to reconnect the two, though.

The Refresh method does not cope with additions or deletions, whereas requery does; Refresh is intended for use where users may be changing existing record values in a multi-user environment.

-Stewart
Aug 18 '10 #2

Jerry Maiapu
100+
P: 259
Stewart,
I just made a change to your solution and bingo it worked.Thanks so much.

Changed
Expand|Select|Wrap|Line Numbers
  1. Me![Mainformname]![SubformControlName].Form.Requery
to:
Expand|Select|Wrap|Line Numbers
  1. Forms![Mainformname]![SubformControlName].Form.Requery
just replaced Me by Forms.
NB: With Me it gave error
Aug 19 '10 #3

P: 1
@Jerry Maiapu
No good deed goes unrewarded: the final solution worked for me also: each new subtotal on each purchase order line is reflected in the purchase order total. Thank you guys.
Sep 17 '16 #4

Post your reply

Sign in to post your reply or Sign up for a free account.