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
592 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now