Solved

Refresh parent form text box that is bound to table when child event runs in Access 2003 vba

Posted on 2014-10-09
3
610 Views
Last Modified: 2014-10-09
Hi all.

I have an Access 2003 ADP file that has a form (ParentA). This form has 3 tabs, one of which is the "Costs" tab. On this tab there is a child form (ChildA). I have an event that runs in this child form every time a certain field is updated, the event updates the "freight" field in TableA. The datasource for ParentA is the TableA table.

There is a field called txtFreight that is bound to this "freight" field in TableA and it is in the ParentA form. So, you have the "Costs" tab, in the detail section you have the child form ChildA and right under the child form you have the txtFreight text box.

The problem I'm having is every time the child form event runs and updates the Freight field in TableA, it does not update the txtFreight field in the tab. I have to close the entire form, then open again and when I go back to the "Costs" tab then I see the updated freight in the txtFreight text box.

Any idea how I can have refresh the txtFreight right from the child form event?

Thank you in advance.
0
Comment
Question by:Sim1980
  • 2
3 Comments
 
LVL 24

Accepted Solution

by:
Bitsqueezer earned 500 total points
ID: 40370554
Hi,

as the you only update and not delete or insert values the parent form has the linked record displayed so you can update that in the child form's event with "Me.Parent.Refresh" which only refreshes updated values and do not change the record pointer.

Cheers,

Christian
0
 

Author Comment

by:Sim1980
ID: 40370662
Thank you for your reply.

I added "Me.Parent.Refresh" and now I get the following error:
Run-time error '2455': You entered an expression that has an invalid reference to the property Form/Report.

When I click the debug button it points to the following line of code:
"Me.ChildFormB!DeleteRecord.Enabled = toEnable"
0
 
LVL 24

Expert Comment

by:Bitsqueezer
ID: 40371005
Hi,

that is a wrong reference, if "ChildFormB" is the name of the subform container control then you need to add ".Form" to access anything on the form.

So this must be:
Me.ChildFormB.Form.DeleteRecord.Enabled = toEnable

Open in new window


That is another issue with your main form and has nothing to do with the Refresh method, you should have got this error even without that.

Cheers,

Christian
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question